private void VerifyPasswords() { if (Database_Connector.GetUserIdByUsernameAndPassword(Main.user.Username, Controls["TB_currentPassword"].Text) == 0) { Controls["TB_currentPassword"].Text = ""; Controls["TB_newPassword"].Text = ""; Controls["TB_confirmPassword"].Text = ""; throw new Exception("PASSWORD_INVALID"); } else if (Controls["TB_newPassword"].Text == String.Empty || Controls["TB_confirmPassword"].Text == String.Empty) { throw new Exception("PASSWORD_EMPTY"); } else if (Controls["TB_currentPassword"].Text == Controls["TB_newPassword"].Text) { Controls["TB_newPassword"].Text = ""; Controls["TB_confirmPassword"].Text = ""; throw new Exception("PASSWORD_SAME"); } else if (Controls["TB_newPassword"].Text != Controls["TB_confirmPassword"].Text) { Controls["TB_confirmPassword"].Text = ""; throw new Exception("PASSWORD_NOT_MATCHING"); } }
public bool Login(string username, string plainPassword) { if (LoggedIn) { throw new Exception("User already logged-in."); } Username = username; UserID = Database_Connector.GetUserIdByUsernameAndPassword(username, plainPassword); if (UserID > 0) { LoggedIn = true; LoadSettings(); LoadPermissions(); return(true); } return(false); }