Ejemplo n.º 1
0
 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");
     }
 }
Ejemplo n.º 2
0
        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);
        }