public async Task LogoutAsync(UserProfile profile, HttpContext httpContext) { string token = await TryGetToken(profile, httpContext); var tokenHandler = new JwtSecurityTokenHandler(); if (!tokenHandler.CanReadToken(token)) { return; } var jwtToken = tokenHandler.ReadJwtToken(token); _tokenCache.Remove(jwtToken.Id); _logger.LogInformation("User logged out."); return; }
public async Task <IActionResult> LogoutAsync([FromBody] UserProfile profile) { string token = await TryGetToken(profile); var tokenHandler = new JwtSecurityTokenHandler(); if (!tokenHandler.CanReadToken(token)) { _logger.LogWarning(LoggingEvents.InvalidAction, "could not logged out.", profile); return(Ok()); } var jwtToken = tokenHandler.ReadJwtToken(token); _tokenCache.Remove(jwtToken.Id); _logger.LogInformation(LoggingEvents.ValidAction, "User logged out."); return(Ok()); }