using SkullLabs; using System; using System.Drawing; using System.Windows.Forms; namespace SkullLabsAuthExample { public partial class Form1 : Form { private readonly AuthClient _auth = new AuthClient(); private TextBox _username; private TextBox _password; private Button _loginBtn; private Label _statusLabel; public Form1() { Text = "Skull Labs Auth - Login"; Size = new Size(380, 280); StartPosition = FormStartPosition.CenterScreen; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; BackColor = Color.FromArgb(12, 13, 17); ForeColor = Color.FromArgb(230, 232, 238); Font = new Font("Segoe UI", 9.5f); var title = new Label { Text = "SKULL LABS AUTH", Font = new Font("Consolas", 11f, FontStyle.Bold), ForeColor = Color.FromArgb(0, 229, 255), Location = new Point(24, 22), Size = new Size(320, 20), }; var userLbl = new Label { Text = "Username", Location = new Point(24, 60), Size = new Size(80, 18), ForeColor = Color.FromArgb(139, 143, 156) }; _username = new TextBox { Location = new Point(24, 80), Size = new Size(320, 24), BackColor = Color.FromArgb(20, 22, 28), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle }; var passLbl = new Label { Text = "Password", Location = new Point(24, 114), Size = new Size(80, 18), ForeColor = Color.FromArgb(139, 143, 156) }; _password = new TextBox { Location = new Point(24, 134), Size = new Size(320, 24), BackColor = Color.FromArgb(20, 22, 28), ForeColor = Color.White, BorderStyle = BorderStyle.FixedSingle, UseSystemPasswordChar = true }; _loginBtn = new Button { Text = "Sign in", Location = new Point(24, 174), Size = new Size(320, 32), BackColor = Color.FromArgb(0, 229, 255), ForeColor = Color.Black, FlatStyle = FlatStyle.Flat, Font = new Font("Segoe UI", 9.5f, FontStyle.Bold), }; _loginBtn.FlatAppearance.BorderSize = 0; _loginBtn.Click += async (s, e) => await Login(); _statusLabel = new Label { Location = new Point(24, 214), Size = new Size(320, 20), TextAlign = ContentAlignment.MiddleCenter, ForeColor = Color.FromArgb(139, 143, 156), Text = "Ready", }; AcceptButton = _loginBtn; Controls.AddRange(new Control[] { title, userLbl, _username, passLbl, _password, _loginBtn, _statusLabel }); } private async System.Threading.Tasks.Task Login() { _loginBtn.Enabled = false; SetStatus("Signing in...", Color.FromArgb(255, 181, 71)); try { var result = await _auth.LoginAsync(_username.Text.Trim(), _password.Text); if (!result.Ok) { SetStatus($"Login failed: {result.Error}", Color.FromArgb(255, 51, 102)); return; } SetStatus("Welcome.", Color.FromArgb(34, 211, 154)); Hide(); using (var f2 = new Form2(result)) { f2.ShowDialog(); } Application.Exit(); } catch (Exception ex) { SetStatus($"Error: {ex.Message}", Color.FromArgb(255, 51, 102)); } finally { _loginBtn.Enabled = true; } } private void SetStatus(string text, Color color) { _statusLabel.Text = text; _statusLabel.ForeColor = color; } } }