Ejemplo n.º 1
0
 public static Task xAddClaimsAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default)
     where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey>
     where TKey : IEquatable <TKey>
     where TUser : class, IIdentityUserWithClaims <TKey>
     where TUserClaim : class, IIdentityUserClaim <TKey>, new()
 {
     store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken);
     if (claims == null)
     {
         throw new ArgumentNullException(nameof(claims));
     }
     foreach (var claim in claims)
     {
         store.Context.DbInsertAsync(user.xCreateUserClaim <TKey, TUserClaim>(claim));
     }
     return(Task.FromResult(false));
 }
Ejemplo n.º 2
0
        public static async Task xReplaceClaimAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default)
            where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey>
            where TKey : IEquatable <TKey>
            where TUser : class, IIdentityUserWithClaims <TKey>
            where TUserClaim : class, IIdentityUserClaim <TKey>
        {
            store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken);
            if (claim == null)
            {
                throw new ArgumentNullException(nameof(claim));
            }
            if (newClaim == null)
            {
                throw new ArgumentNullException(nameof(newClaim));
            }
            var matchedClaims = await(store.Context.DbGetQueryable <TUserClaim>().Where(user, claim).Where(user, claim)).xToListAsync(cancellationToken);

            foreach (var matchedClaim in matchedClaims)
            {
                matchedClaim.ClaimValue = newClaim.Value;
                matchedClaim.ClaimType  = newClaim.Type;
            }
        }
Ejemplo n.º 3
0
        public static async Task xRemoveClaimsAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default)
            where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey>
            where TKey : IEquatable <TKey>
            where TUser : class, IIdentityUserWithClaims <TKey>
            where TUserClaim : class, IIdentityUserClaim <TKey>
        {
            store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken);
            if (claims == null)
            {
                throw new ArgumentNullException(nameof(claims));
            }
            foreach (var claim in claims)
            {
                var matchedClaims = await store.Context.DbGetQueryable <TUserClaim>().Where(user, claim).xToListAsync(cancellationToken);

                foreach (var c in matchedClaims)
                {
                    await store.Context.DbDeleteAsync(c);
                }
            }
        }
Ejemplo n.º 4
0
 public static async Task <IList <TUser> > xGetUsersForClaimAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, Claim claim, CancellationToken cancellationToken = default)
     where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey>
     where TKey : IEquatable <TKey>
     where TUser : class, IIdentityUserWithClaims <TKey>
     where TUserClaim : class, IIdentityUserClaim <TKey>
 {
     store.ThrowIfCancelledRequestOrDisposed(cancellationToken);
     if (claim == null)
     {
         throw new ArgumentNullException(nameof(claim));
     }
     return(await store.Context.DbGetQueryable <TUserClaim>().xGetUsersForClaimAsync(store.Context.DbGetQueryable <TUser>(), claim, cancellationToken));
 }
Ejemplo n.º 5
0
 public static async Task <IList <Claim> > xGetClaimsAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, CancellationToken cancellationToken = default)
     where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey>
     where TKey : IEquatable <TKey>
     where TUser : class, IIdentityUserWithClaims <TKey>
     where TUserClaim : class, IIdentityUserClaim <TKey>
 {
     store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken);
     return(await store.Context.DbGetQueryable <TUserClaim>().xGetClaimsAsync(user, cancellationToken));
 }