public async Task <IActionResult> RefreshToken([FromBody] RefreshTokenViewModel model) { string refreshToken = model.RefreshToken; if (string.IsNullOrWhiteSpace(refreshToken)) { return(BadRequest("refreshToken is not set.")); } (Token token, User user) = await jwtTokenService.FindUserAndTokenByRefreshTokenAsync(refreshToken); if (token == null) { return(Unauthorized()); } var result = jwtTokenService.CreateJwtTokens(user); await jwtTokenService.AddUserTokenAsync(user, result.RefreshTokenSerial, result.AccessToken, jwtTokenService.GetRefreshTokenSerial(refreshToken)); return(Ok(new { access_token = result.AccessToken, refresh_token = result.RefreshToken })); }