public async Task <IActionResult> Login([FromBody] LoginRequestModel model) { if (User.Identity.IsAuthenticated) { return(Forbid()); } try { var user = await _userAuthenticationService.FindUserByCredentialsAsync(model); var token = _userAuthenticationService.CreateJwtToken(_userAuthenticationService.CreateClaims(user), _jwtOptions); var response = new { AccessToken = token, User = _mapper.Map <UserViewModel>(user) }; return(Ok(response)); } catch (NotFoundException) { return(this.BadRequestError("Invalid login data.")); } }