public async Task <TokenModel> SignUpAsync(string username, string password) { await Task.Delay(2000); ValidateUserData(username, password); var userModel = new UserModel { UserName = username }; return(_userTokenService.CreateToken(userModel)); }
public IActionResult Authenticate([FromBody] UserCredentialsDTO userCredentials) { var user = _userService.Authenticate(userCredentials.Username, userCredentials.Password); if (user == null) { return(BadRequest(new { message = "Username or password is incorrect" })); } var userDTO = _mapper.Map <UserDTO>(user); userDTO.Token = _userTokenService.CreateToken(user); return(Ok(userDTO)); }