public User Create(CreateUserRequest userRequest) { var user = userRequest.ToUser(); user.Password = Encrypted.Sha256(user.Password); fileRepository.Save(userRequest.Photo, userRequest.PhotoName); return(userRepository.Create(user)); }
public LoginReponse Login(LoginRequest loginRequest) { var user = userRepository.IsValidUserCredentials(loginRequest.Username, Encrypted.Sha256(loginRequest.Password)); if (user == null) { throw new UnauthorizedAccessException(); } return(authRepository.GenerateTokens(user)); }
public void Update(UpdateUserRequest userRequest) { var user = userRequest.ToUser(); if (!string.IsNullOrEmpty(user.Password)) { user.Password = Encrypted.Sha256(user.Password); } if (!string.IsNullOrEmpty(userRequest.Photo)) { fileRepository.Save(userRequest.Photo, userRequest.PhotoName); } userRepository.Update(userRequest.ToUser()); }