/// <inheritdoc/> public override async Task RemoveClaimsAsync(TUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken) { ThrowIfDisposed(); user.ThrowIfNull(nameof(user)); claims.ThrowIfNull(nameof(claims)); UserClaims ??= (await UserClaimsTable.GetClaimsAsync(user.Id)).ToList(); foreach (var claim in claims) { var matchedClaims = UserClaims.Where(x => x.UserId.Equals(user.Id) && x.ClaimType == claim.Type && x.ClaimValue == claim.Value); foreach (var matchedClaim in matchedClaims) { UserClaims.Remove(matchedClaim); } } }
public override async Task RemoveClaimsAsync(User user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default) { ThrowIfDisposed(); user.CheakArgument(); claims.CheakArgument(); foreach (var claim in claims) { var matchedClaims = await UserClaims.Where(uc => uc.UserId.Equals(user.Id) && uc.ClaimValue == claim.Value && uc.ClaimType == claim.Type).ToListAsync(); foreach (var c in matchedClaims) { UserClaims.Remove(c); } } }
public void RemoveNoIdentityClaims() { if (UserClaims == null) { return; } for (var i = UserClaims.Count - 1; i >= 0; i--) { var claim = UserClaims.ElementAt(i); if (claim.ClaimType != "given_name") { UserClaims.Remove(claim); } } }
/// <summary> /// Removes the <paramref name="claims"/> given from the specified <paramref name="user"/>. /// </summary> /// <param name="user">The user to remove the claims from.</param> /// <param name="claims">The claim to remove.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> /// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns> public async override Task RemoveClaimsAsync(User user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); if (user == null) { throw new ArgumentNullException(nameof(user)); } if (claims == null) { throw new ArgumentNullException(nameof(claims)); } foreach (var claim in claims) { var matchedClaims = await UserClaims.Where(uc => uc.UserId.Equals(user.Id) && uc.ClaimValue == claim.Value && uc.ClaimType == claim.Type).ToListAsync(cancellationToken); foreach (var c in matchedClaims) { UserClaims.Remove(c); } } }
public void RemoveClaim(IdentityUserClaim <Guid> item) { UserClaims.Remove(item); }