소스 검색

Fixed refresh token bug

pull/177/head
bronjaermin 3 년 전
부모
커밋
082897f548

+ 2
- 1
Diligent.WebAPI.Business/Services/AdService.cs 파일 보기

@@ -91,8 +91,9 @@
public async Task<List<AdResponseDto>> GetFilteredAdsAsync(AdFilterDto filters)
{
_logger.LogInformation($"Start getting all filtered Ads");
var today = DateTime.Now;
_logger.LogInformation("Getting data from DB");
var filteredAds = await _context.Ads.Include(x => x.Technologies).ToListAsync();
var filteredAds = await _context.Ads.Include(x => x.Technologies).Where(x => x.ExpiredAt > today).ToListAsync();
_logger.LogInformation($"Received {filteredAds.Count} ads from db.");

_logger.LogInformation($"Mapping received ads to AdResponseDto");

+ 2
- 2
Diligent.WebAPI.Business/Services/AuthenticationService.cs 파일 보기

@@ -231,9 +231,9 @@ namespace Diligent.WebAPI.Business.Services
var expiryDateUnix = long.Parse(validatedToken.Claims.Single(x => x.Type == JwtRegisteredClaimNames.Exp).Value);

var expiryDateTimeUtc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
.AddMinutes(expiryDateUnix);
.AddSeconds(expiryDateUnix);

if (expiryDateTimeUtc < DateTime.Now)
if (expiryDateTimeUtc > DateTime.UtcNow)
{
return new RefreshTokenResultDto
{

+ 5
- 2
Diligent.WebAPI.Host/Middlewares/JwtMiddleware.cs 파일 보기

@@ -63,9 +63,12 @@
if (refreshToken == null)
return;

refreshToken.ExpiryDate = DateTime.Now.AddMinutes(30);
if(refreshToken.ExpiryDate > DateTime.Now)
{
refreshToken.ExpiryDate = DateTime.Now.AddMinutes(_authSettings.JwtRefreshExpiredTime);

await service.UpdateRefreshToken(refreshToken);
await service.UpdateRefreshToken(refreshToken);
}
}
}
}

Loading…
취소
저장