Advertisement
Guest User

Untitled

a guest
Oct 26th, 2023
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11. using System.IO;
  12.  
  13. namespace Midnight_Serverpanel
  14. {
  15.  
  16. public partial class login : Form
  17. {
  18. public login()
  19. {
  20. InitializeComponent();
  21. }
  22.  
  23. private void button1_Click_1(object sender, EventArgs e)
  24. {
  25.  
  26. this.Hide();
  27. Start sistema = new Start();
  28. sistema.ShowDialog();
  29. this.Close();
  30. }
  31. public bool IsUserLoggedIn()
  32. {
  33. string tokenFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Google.Apis.Auth", "Google.Apis.Auth.OAuth2.Responses.TokenResponse-user");
  34.  
  35. try
  36. {
  37. if (File.Exists(tokenFilePath))
  38. {
  39. // Überprüfen, ob die Datei einen gültigen Inhalt hat
  40. string tokenContent = File.ReadAllText(tokenFilePath);
  41. if (!string.IsNullOrEmpty(tokenContent))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. catch (Exception ex)
  48. {
  49. // Hier könntest du die Fehlermeldung protokollieren oder debuggen
  50. MessageBox.Show("Fehler beim Überprüfen des Tokens: " + ex.Message);
  51. }
  52.  
  53. return false;
  54. }
  55.  
  56. private void login_Load(object sender, EventArgs e)
  57. {
  58. try
  59. {
  60. if (IsUserLoggedIn())
  61. {
  62.  
  63. OpenStartForm();
  64. this.Hide();
  65. }
  66. }
  67. catch (Exception ex)
  68. {
  69. MessageBox.Show("Fehler beim Laden des Startformulars: " + ex.Message);
  70. }
  71. }
  72. private void OpenStartForm()
  73. {
  74. try
  75. {
  76. // Öffne das Startformular
  77. Start sistema = new Start();
  78.  
  79. sistema.Show();
  80. MessageBox.Show("Benutzer ist angemeldet"); // Füge diese Zeile für die Fehlersuche hinzu
  81.  
  82. // Schließe das aktuelle Loginformular
  83. this.Hide();
  84. }
  85. catch (Exception ex)
  86. {
  87. MessageBox.Show("Fehler beim Öffnen des Startformulars: " + ex.Message);
  88. }
  89. }
  90. }
  91.  
  92. }
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement