Beispiel #1
0
        public virtual void AddOrUpdateLinkedAccount(string provider, string id, IEnumerable <Claim> claims = null)
        {
            Tracing.Information("[UserAccount.AddOrUpdateLinkedAccount] called for accountID: {0}", this.ID);

            if (String.IsNullOrWhiteSpace(provider))
            {
                Tracing.Error("[UserAccount.AddOrUpdateLinkedAccount] failed -- null provider");
                throw new ArgumentNullException("provider");
            }
            if (String.IsNullOrWhiteSpace(id))
            {
                Tracing.Error("[UserAccount.AddOrUpdateLinkedAccount] failed -- null id");
                throw new ArgumentNullException("id");
            }

            var linked = GetLinkedAccount(provider, id);

            if (linked == null)
            {
                linked = new LinkedAccount
                {
                    ProviderName      = provider,
                    ProviderAccountID = id
                };
                this.LinkedAccounts.Add(linked);
                this.AddEvent(new LinkedAccountAddedEvent {
                    Account = this, LinkedAccount = linked
                });

                Tracing.Verbose("[UserAccount.AddOrUpdateLinkedAccount] linked account added");
            }
            UpdateLinkedAccount(linked, claims);
        }
Beispiel #2
0
        protected virtual void UpdateLinkedAccount(LinkedAccount account, IEnumerable <Claim> claims = null)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }

            account.LastLogin = UtcNow;
            account.UpdateClaims(claims);
        }
Beispiel #3
0
        protected virtual void UpdateLinkedAccount(LinkedAccount account, IEnumerable <Claim> claims = null)
        {
            Tracing.Information("[UserAccount.UpdateLinkedAccount] called for accountID: {0}", this.ID);

            if (account == null)
            {
                Tracing.Error("[UserAccount.UpdateLinkedAccount] failed -- null account");
                throw new ArgumentNullException("account");
            }

            account.LastLogin = UtcNow;
            account.UpdateClaims(claims);
        }
        public static bool HasClaim(this LinkedAccount account, string type)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }
            if (String.IsNullOrWhiteSpace(type))
            {
                throw new ArgumentException("type");
            }

            return(account.Claims.Any(x => x.Type == type));
        }
        public static string GetClaimValue(this LinkedAccount account, string type)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }
            if (String.IsNullOrWhiteSpace(type))
            {
                throw new ArgumentException("type");
            }

            var query =
                from claim in account.Claims
                where claim.Type == type
                select claim.Value;

            return(query.SingleOrDefault());
        }
Beispiel #6
0
        public virtual void AddOrUpdateLinkedAccount(string provider, string id, IEnumerable <Claim> claims = null)
        {
            if (String.IsNullOrWhiteSpace(provider))
            {
                throw new ArgumentNullException("provider");
            }
            if (String.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("id");
            }

            var linked = GetLinkedAccount(provider, id);

            if (linked == null)
            {
                linked = new LinkedAccount
                {
                    ProviderName      = provider,
                    ProviderAccountID = id
                };
                this.LinkedAccounts.Add(linked);
            }
            UpdateLinkedAccount(linked, claims);
        }
        protected virtual void UpdateLinkedAccount(LinkedAccount account, IEnumerable<Claim> claims = null)
        {
            if (account == null) throw new ArgumentNullException("account");

            account.LastLogin = UtcNow;
            account.UpdateClaims(claims);
        }
        public virtual void AddOrUpdateLinkedAccount(string provider, string id, IEnumerable<Claim> claims = null)
        {
            if (String.IsNullOrWhiteSpace(provider)) throw new ArgumentNullException("provider");
            if (String.IsNullOrWhiteSpace(id)) throw new ArgumentNullException("id");

            var linked = GetLinkedAccount(provider, id);
            if (linked == null)
            {
                linked = new LinkedAccount
                {
                    ProviderName = provider,
                    ProviderAccountID = id
                };
                this.LinkedAccounts.Add(linked);
            }
            UpdateLinkedAccount(linked, claims);
        }
 protected internal abstract void RemoveLinkedAccount(LinkedAccount item);
Beispiel #10
0
 protected internal abstract void AddLinkedAccount(LinkedAccount item);
 protected internal abstract void RemoveLinkedAccount(LinkedAccount item);
 protected internal abstract void AddLinkedAccount(LinkedAccount item);