public IActionResult LoginByCustomer([FromBody] LoginByCustomerCommand command) { string email = command.Email; string pin = command.Pin; bool changePinResult = _authService.ChangePin(email, pin); if (!changePinResult) { return(null); } LoginByCustomerDto loginByCustomerDto = _authService.LoginByCustomer(email, pin); if (loginByCustomerDto == null) { return(NotFound()); } GetToken getToken = new GetToken(_configuration); LoginByCustomerViewModel model = _mapper.Map <LoginByCustomerViewModel>(loginByCustomerDto); model.Token = getToken.Token; model.RefreshToken = _authService.GetRefreshToken(email); return(Ok(model)); }
public LoginByCustomerDto LoginByCustomer(string email, string pin) { UserEntity user = _userRepository.GetUserByEmail(email); if (user == null) { return(null); } string checkPassword = Generator.HashPassword(pin, user.Salt); if (checkPassword == user.Pin) { LoginByCustomerDto loginUser = _mapper.Map <LoginByCustomerDto>(user); return(loginUser); } return(null); }