public async Task <IActionResult> TokenAsync([FromBody] UserLoginModelRequest loginModel) { if (!ModelState.IsValid) { return(BadRequest()); } try { var userId = await _accountService.LogisTask(loginModel); var userToken = _jwtTokenService.GenerateJwtTokenTask(userId); return(StatusCode(200, JsonConvert.SerializeObject(new JwtSecurityTokenHandler().WriteToken(userToken)))); } catch (UserNotFoundException ex) { return(StatusCode(404, ex.Message)); } catch (Exception ex) { _logger.Error(ex); return(StatusCode(500, "Internal server error")); } }