/// <summary> /// Checks if the user with the specified ID has used the specified password /// recently (ie. within the last 24 password changes). /// Returns true if they have, otherwise false. /// </summary> public static bool IsRecentPassword(User user, string password) { // Get the last 24 passwords UserPasswordHistoryFinder finder = new UserPasswordHistoryFinder { UserId = user.UserId.GetValueOrDefault(-1), MaxRecords = 24 }; finder.SortExpressions.Add(new DescendingSort(UserPasswordHistory.Columns.Date)); EntityList <UserPasswordHistory> passwordHistory = UserPasswordHistory.FindMany(finder); return(passwordHistory.Any(uph => StringHasher.VerifyHash(uph.Password, password + user.PasswordSalt))); }
public static User GetUser(int userId, string hash, string guid) { UserFinder finder = new UserFinder { UserId = userId, Guid = guid }; User u = User.FindOne(finder); if (StringHasher.VerifyHash(hash, u.Email)) { return(u); } return(User.Empty); }
/// <summary> /// Checks if the specified password matches the user's password /// </summary> public virtual bool CheckPassword(string password) { return(StringHasher.VerifyHash(Password, password + PasswordSalt)); }
public void AnswerIsValid(string value) { string passwordHash = _stringHasher.ComputeHash(PASSWORD); _stringHasher.VerifyHash(value, passwordHash); }