// do Change the userPassword with the newPassword
 private IActionResult _DoChangePassword(User user, string newPassword)
 {
     // (3) hashing the new password and set the passwordSalt and passwordHash
     user.PasswordSalt = UserHelpers.GetSecuredRandStr();
     user.PasswordHash = UserHelpers.Hashing(newPassword, user.PasswordSalt);
     // (4) Saving the new passwordSalt and passwordHash
     _service.Save();
     // (5) Map the Entity User to View User [VUser]
     vUser = _mapper.Map <UserView>(user);
     // (6) if everything is ok, return the full vUser
     return(Ok(vUser));
 }
Exemplo n.º 2
0
        public static User ToUser(SignUp signUp)
        {
            // generate salt and hash
            string salt = UserHelpers.GetSecuredRandStr();
            string hash = UserHelpers.Hashing(signUp.Password, salt);

            return(new User()
            {
                UserName = signUp.UserName,
                Email = signUp.Email,
                Address = signUp.Address,
                Mobile = signUp.Mobile,
                BirthDate = signUp.BirthDate,
                Gender = signUp.Gender,
                PasswordSalt = salt,
                PasswordHash = hash
            });
        }