internal static ValidationEnum SetPassword(string userName, string unhashedPassword1, string unhashedPassword2) { var user = Maintenance.Users.SingleOrDefault(u => u.Name.ToUpper() == userName.ToUpper()); if (user == null) { return(ValidationEnum.FailedUserNotFound); } if (string.IsNullOrWhiteSpace(unhashedPassword1)) { return(ValidationEnum.PasswordRequired); } if (unhashedPassword1 != unhashedPassword2) { return(ValidationEnum.PasswordsDoNotMatch); } user.HashedPassword = User.Hash(user.Name, unhashedPassword1); var change = new Change(user, "password", "old", "new"); ChangeLog.LogDiff(change); Maintenance.SaveUsers(); ValidateUser(userName, unhashedPassword1); return(ValidationEnum.PasswordChanged); }