コード例 #1
0
        public async Task <DBStatus> RegisterAsync(UserRegistrationDTO userRegistrationDTO)
        {
            string passwordHash = ConverterSuit.ByteArrayToHex(HashSuit.ComputeSha256(Encoding.UTF8.GetBytes(userRegistrationDTO.Password)));
            User   user         = mapper.Map <User>(userRegistrationDTO);

            user.PasswordHash = passwordHash;
            DBStatus status = await authRepository.RegisterAsync(user);

            return(status);
        }
コード例 #2
0
        public async Task <LoggedInUserDTO> LoginAsync(UserCredentialsDTO credentialsDTO)
        {
            string passwordHash = ConverterSuit.ByteArrayToHex(HashSuit.ComputeSha256(Encoding.UTF8.GetBytes(credentialsDTO.Password)));
            User   user         = await authRepository.LoginAsync(credentialsDTO.UserId, passwordHash);

            if (user == null)
            {
                return(null);
            }

            LoggedInUserDTO loggedInUser = mapper.Map <LoggedInUserDTO>(user);

            loggedInUser.JwtToken = jwtSuit.GetToken(user);
            return(loggedInUser);
        }
コード例 #3
0
 public Task <DBStatus> UpdateUserPasswordAsync(UpdateUserPasswordDTO passwordDTO)
 {
     passwordDTO.NewPassword = ConverterSuit.ByteArrayToHex(HashSuit.ComputeSha256(Encoding.UTF8.GetBytes(passwordDTO.NewPassword)));
     passwordDTO.OldPassword = ConverterSuit.ByteArrayToHex(HashSuit.ComputeSha256(Encoding.UTF8.GetBytes(passwordDTO.OldPassword)));
     return(userRepository.UpdateUserPasswordAsync(passwordDTO));
 }