| public async Task<List<AdResponseDto>> GetFilteredAdsAsync(AdFilterDto filters) | public async Task<List<AdResponseDto>> GetFilteredAdsAsync(AdFilterDto filters) | ||||
| { | { | ||||
| _logger.LogInformation($"Start getting all filtered Ads"); | _logger.LogInformation($"Start getting all filtered Ads"); | ||||
| var today = DateTime.Now; | |||||
| _logger.LogInformation("Getting data from DB"); | _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($"Received {filteredAds.Count} ads from db."); | ||||
| _logger.LogInformation($"Mapping received ads to AdResponseDto"); | _logger.LogInformation($"Mapping received ads to AdResponseDto"); |
| var expiryDateUnix = long.Parse(validatedToken.Claims.Single(x => x.Type == JwtRegisteredClaimNames.Exp).Value); | 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) | 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 | return new RefreshTokenResultDto | ||||
| { | { |
| if (refreshToken == null) | if (refreshToken == null) | ||||
| return; | 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); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } |