public async Task <ActionResult <User> > Register(CreateUser newUser) { if (newUser.Password != newUser.ConfirmPassword) { return(BadRequest(new ApiError() { Error = "[ConfirmPassword] and [Password] must match" })); } var user = _mapper.Map <UserEntity>(newUser); user.Password = CredentialsCypher.ToSha256(user.Password); var result = await _userRepository.RegisterAsync(user); var link = _linker.GetPathByAction(HttpContext, nameof(Login)); return(Created(link, _mapper.Map <User>(result))); }
public bool IsAuthorized(string candidatePassword) { var hashedPwd = CredentialsCypher.ToSha256(candidatePassword); return(Password == hashedPwd); }