public AdminWindow(AccountHandler accountHandler) { InitializeComponent(); SetPassResetState(false); _ah = accountHandler; RefreshDataGrid(); }
private void btnLogin_Click(object sender, EventArgs e) { if (!HasValidInput()) { MessageBox.Show("Please fill in your username and password!", "Oops..."); return; } if (!txtName.Text.Contains("@")) { MessageBox.Show("Invalid mail!", "Oops..."); return; } try { HashHandler hasher = new HashHandler($"{txtName.Text}:{txtPass.Text}", Scrambler); AccountHandler accountHandler = new AccountHandler(hasher, _filer); if (accountHandler.IsValidPass()) { Account user = accountHandler.GetAccount(); if (user.Permission is AccountPermission.Admin) { this.Hide(); AdminWindow aw = new AdminWindow(accountHandler); aw.Closed += (s, args) => this.Close(); aw.Show(); } else { this.Hide(); MemberWindow mw = new MemberWindow(); mw.Closed += (s, args) => this.Close(); mw.Show(); } } else { MessageBox.Show("You provided the wrong credentials!", "Oops..."); } } catch (Exception exception) { MessageBox.Show($"Oh, it seems like an unexpected error occurred!\r\n{exception.Message}", "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); } }