private void LoginButton_Click(object sender, RoutedEventArgs e) { // Try authenticating with given username and password var uaHandler = new SecurityHandler(); //var user = uaHandler.TryAuthentication(UsernameTextBox.Text, PasswordBox.Password); var user = uaHandler.TryAuthentication("piyal", "piyal123"); // If user returned is null, show error and return if (user == null) { MessageBox.Show("Invalid username or password", "Error", MessageBoxButton.OK); PasswordBox.Focus(); PasswordBox.SelectAll(); return; } // Else assign it to currentuser and show home window Session.CurrentUser = user; Session.Clearance = new Clearance(user.AccessMode); if (Session.CurrentUser.IsDefaultPassword()) { new ChangePasswordDialog().ShowDialog(); } new HomeWindow().Show(); Close(); }
private void AuthenticateButton_Click(object sender, RoutedEventArgs e) { var user = _securityHandler.TryAuthentication(UsernameTextBox.Text, PasswordBox.Password); if (user != null) { if (user.AccessMode == AccessMode.Manager) { DialogResult = true; } Close(); } else { MessageBox.Show("Not Authorized", "Error", MessageBoxButton.OK); } }