private void btnLogin_Click(object sender, EventArgs e) { try { var model = new Login { Email = txtUsername.Text.Trim(), Password = PasswordHash.sha256(txtPassword.Text) }; if (model.Email.Length == 0 || model.Password.Length == 0) { Base.ShowError("Required fields missing", "Email and Password cannot be empty"); return; } if (!Validations.IsValidEmail(model.Email)) { Base.ShowError("Invalid Email", "Email is invalid"); return; } if (_authRepo.StaffLogin(model)) { if (!LoggedInUser.PasswordChanged) // first time login { Base.ShowInfo("First time Login", "This is your first login with the default password. Kindly change your password"); var pwdForm = new FrmChangePassword(LoggedInUser.Email); pwdForm.ShowDialog(); pwdForm.BringToFront(); } using (var dashboard = new FrmContainer()) { this.Hide(); this.ShowInTaskbar = false; dashboard.ShowDialog(); dashboard.BringToFront(); } } else { Base.ShowError("Invalid Login", "Username and Password is incorrect"); return; } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private void iconUser_Click(object sender, EventArgs e) { if (LoggedInUser.UserId == Helper.SuperAdminId) { Base.ShowError("Access Denied", "You cannot change system admin password from here. Go to Settings"); return; } if (Helper.CheckRemoteServerConnection()) { var frm = new FrmChangePassword(LoggedInUser.Email); frm.ShowDialog(); } else { Base.ShowError("Connection Failed", "You can only change passwords while connected to the remote server. Check your connection settings"); } }