Пример #1
0
        private User CreateNewUser(CreateUserViewModel user)
        {
            string salt = string.Empty;

            User newUser = new User
            {
                Username = user.Username,
                Email = user.Email,
                DOB = user.DOB,
                PasswordHash = _passwordManager.GeneratePasswordHash(user.Password, out salt),
                Salt = salt
            };

            return newUser;
        }
Пример #2
0
        private void HasPasswordChanged(EditUserViewModel updateUserPassword, User usersOriginalPassword)
        {
            bool passwordMatch = _passwordManager.IsPasswordMatch(updateUserPassword.CurrentPassword, usersOriginalPassword.Salt, usersOriginalPassword.PasswordHash);


            if (!string.IsNullOrEmpty(updateUserPassword.CurrentPassword))
            {
                //check to see if matches that in database
                if (passwordMatch)
                {
                    //Save new password
                    string salt = string.Empty;
                    usersOriginalPassword.PasswordHash = _passwordManager.GeneratePasswordHash(updateUserPassword.NewPassword, out salt);
                    usersOriginalPassword.Salt = salt;
                }
            }
        }