return new Country() ;
public async Task<Country?> GetCountry(string countryCode, CancellationToken cancellationToken)
{
var countries = await SearchCountries("en-gb", cancellationToken);
return countries.Value?.FirstOrDefault(x => string.Equals(x.Code, countryCode));
}
LifetimeValidator lifetimeValidator = (DateTime? notBefore, DateTime? expires, SecurityToken securityToken, TokenValidationParameters validationParameters) =>
{
if (expires != null && notBefore != null)
{
if (DateTime.UtcNow < expires.Value.ToUniversalTime() & DateTime.UtcNow > notBefore.Value.ToUniversalTime())
{
return true; // Still valid
}
}
return false; // Expired
};
if (_authToken != null & tokenHandler.CanReadToken(_authToken) & _authToken?.Length == 348)
{
var jwtSecurityToken = tokenHandler.ReadJwtToken(_authToken);
SecurityToken validatedToken;
IPrincipal principal = tokenHandler.ValidateToken(_authToken, GetValidationParameters(), out validatedToken);
if (lifetimeValidator(validatedToken.ValidFrom, validatedToken.ValidTo, jwtSecurityToken, GetValidationParameters()))
{
if(principal?.Identity?.Name != null)
{
return true; // Token is valid
}
}
else
{
return false; // Token is expired
}
}
return false; // Token is damaged
}