src/NuGetGallery.Services/Extensions/PrincipalExtensions.cs
/// <summary>
/// Try to remove the claim from the identity
/// </summary>
/// <param name="identity">IIdentity from which the claim is to be removed</param>
/// <param name="claimType">The claim type to be removed</param>
/// <returns>True if successfully able to remove the claim, false otherwise</returns>
Try to remove the claim from the identity
Try to remove the claim from the identity
public static bool TryRemoveClaim(this IIdentity identity, string claimType)
        {
            var claimsIdentity = identity as ClaimsIdentity;
            var claim = claimsIdentity?.FindFirst(claimType);
            if (claim != null)
            {
                return claimsIdentity.TryRemoveClaim(claim);
            }
            return false;
        }
public static bool TryRemoveClaim ( this IIdentity identity , string claimType ) { var claimsIdentity = identity as ClaimsIdentity ; var claim = claimsIdentity ? . FindFirst ( claimType ) ; if ( claim != null ) { return claimsIdentity . TryRemoveClaim ( claim ) ; } return false ; }
Try to remove the claim from the identity
Try to remove the claim from the identity
True if successfully able to remove the claim, false otherwise
True if successfully able to remove the claim false otherwise
IIdentity
this
claimType
string
The claim type to be removed
The claim type to be removed
identity
IIdentity from which the claim is to be removed
IIdentity from which the claim is to be removed