Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- using System.IO;
- namespace Midnight_Serverpanel
- {
- public partial class login : Form
- {
- public login()
- {
- InitializeComponent();
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- this.Hide();
- Start sistema = new Start();
- sistema.ShowDialog();
- this.Close();
- }
- public bool IsUserLoggedIn()
- {
- string tokenFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Google.Apis.Auth", "Google.Apis.Auth.OAuth2.Responses.TokenResponse-user");
- try
- {
- if (File.Exists(tokenFilePath))
- {
- // Überprüfen, ob die Datei einen gültigen Inhalt hat
- string tokenContent = File.ReadAllText(tokenFilePath);
- if (!string.IsNullOrEmpty(tokenContent))
- {
- return true;
- }
- }
- }
- catch (Exception ex)
- {
- // Hier könntest du die Fehlermeldung protokollieren oder debuggen
- MessageBox.Show("Fehler beim Überprüfen des Tokens: " + ex.Message);
- }
- return false;
- }
- private void login_Load(object sender, EventArgs e)
- {
- try
- {
- if (IsUserLoggedIn())
- {
- OpenStartForm();
- this.Hide();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Fehler beim Laden des Startformulars: " + ex.Message);
- }
- }
- private void OpenStartForm()
- {
- try
- {
- // Öffne das Startformular
- Start sistema = new Start();
- sistema.Show();
- MessageBox.Show("Benutzer ist angemeldet"); // Füge diese Zeile für die Fehlersuche hinzu
- // Schließe das aktuelle Loginformular
- this.Hide();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Fehler beim Öffnen des Startformulars: " + ex.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement