public async Task <IActionResult> Login(LoginUserViewModel loginUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User user = await userService.FindUserByUsernameAndPasswordAsync(loginUser.UserName, loginUser.Password); if (user == null) { return(NotFound()); } if (user.IsActive == false) { return(Unauthorized()); } JwtTokensData jwtToken = jwtTokenService.CreateJwtTokens(user); await jwtTokenService.AddUserTokenAsync(user, jwtToken.RefreshTokenSerial, jwtToken.AccessToken, null); return(Ok(new { accessToken = jwtToken.AccessToken, refreshToken = jwtToken.RefreshToken })); }