I have implemented JWT Bearer token base authentication and authorization. I am using the below code for destroying the JWT token or logout the current user but it's not working.
//var claim = _httpContextAccessor.HttpContext.User.Claims;
// var users = await _userManager.FindByNameAsync(_httpContextAccessor.HttpContext.User.Identity.Name);
// var identity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity;
// foreach (var item in claim)
// {
// identity.RemoveClaim(item);
// }
await _signInManager.SignOutAsync();
It is not possible to cancel/revoke a JWT token during user's logout, it is not straightforward, but there is a workaround to that. You can try following the steps below:
I am also pasting 2 links below that myself found very helpful:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With