Beispiel #1
0
        public Task AddClaimAsync(TUser user, Claim claim)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (claim == null)
            {
                throw new ArgumentNullException("claim");
            }

            UserClaimRepository.Insert(new IdentityUserClaim {
                UserId = user.Id, ClaimType = claim.Type, ClaimValue = claim.Value
            });

            return(Task.FromResult <object>(null));
        }
Beispiel #2
0
        public Task AddClaimAsync(TUser user, Claim claim)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (!user.Claims.Any(x => x.ClaimType == claim.Type && x.ClaimValue == claim.Value))
            {
                user.Claims.Add(new IdentityUserClaim
                {
                    ClaimType  = claim.Type,
                    ClaimValue = claim.Value
                });

                _userClaimRepository.Insert(user, claim);
            }
            return(Task.FromResult(0));
        }