Esempio n. 1
0
 /// <summary>
 /// Attempts the admin login.
 /// </summary>
 /// <param name="username">The username.</param>
 /// <param name="password">The password.</param>
 /// <returns></returns>
 public static bool AttemptAdminLogin(string username, string password)
 {
     try
     {
         var dba         = new AdminDatabaseAccess();
         var hashAndSalt = dba.AuthenticateAdminLogin(username);
         var t           = new HashSalt();
         t.makeHashSalt(password);
         var h = t.Hash;
         var s = t.Salt;
         if (hashAndSalt.Count == 2)
         {
             var hashSalt = new HashSalt();
             var hash     = hashAndSalt[0];
             var salt     = hashAndSalt[1];
             var verify   = hashSalt.verifyPassword(password, hash, salt);
             if (verify)
             {
                 var information      = dba.GetAdminsName(username);
                 var loginCredentials = new Admin(information[0], information[1]);
                 ActiveUser = new User(loginCredentials, int.Parse(username))
                 {
                     IsAdmin = true
                 };
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }