private void loginToolStripMenuItem_Click(object sender, EventArgs e) { try{ LoginForm loginForm = new LoginForm(); DialogResult loginresult = loginForm.ShowDialog(this); if (loginresult == DialogResult.OK) { string email = loginForm.email; string password = loginForm.password; if (UserCtx.Login(email, password, out uctx)) { label1.Text = email; ShowComponents(uctx); } else { MessageBox.Show("No such user exists"); } } loginForm.Dispose(); } catch (System.Security.SecurityException se) { MessageBox.Show("Permission denied" + se.Message); } catch (Exception se) { MessageBox.Show(se.Message); } }
private void zalogujToolStripMenuItem_Click(object sender, EventArgs e) { var logging = new Login(); var result = logging.ShowDialog(); if (result == DialogResult.OK) { string username = logging.ReturnValue1; //values preserved after close string password = logging.ReturnValue2; bool loggingResult = UserCtx.Login(username, password, out _userCtx); ShowComponents(_userCtx); if (!loggingResult) { MessageBox.Show("Błąd logowania: nieprawidłowy login lub hasło. \nSpróbuj ponownie"); } if (!_userCtx.HasRoleRight(Operation.Admin)) { MessageBox.Show("Użytkownik nie posiada praw administratora"); UserCtx.Logout(ref _userCtx); } } }