コード例 #1
0
ファイル: UserValues.cs プロジェクト: yashodhank/squidex
        public IEnumerable <Claim> ToClaims()
        {
            if (!string.IsNullOrWhiteSpace(DisplayName))
            {
                yield return(new Claim(SquidexClaimTypes.DisplayName, DisplayName));
            }

            if (!string.IsNullOrWhiteSpace(PictureUrl))
            {
                yield return(new Claim(SquidexClaimTypes.PictureUrl, PictureUrl));
            }

            if (Hidden.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.Hidden, Hidden.ToString()));
            }

            if (Consent.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.Consent, Consent.ToString()));
            }

            if (ConsentForEmails.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.ConsentForEmails, ConsentForEmails.ToString()));
            }

            if (Permissions != null)
            {
                foreach (var permission in Permissions)
                {
                    yield return(new Claim(SquidexClaimTypes.Permissions, permission.Id));
                }
            }
        }
コード例 #2
0
        private IEnumerable <Claim> ToClaimsCore(bool initial)
        {
            if (!string.IsNullOrWhiteSpace(DisplayName))
            {
                yield return(new Claim(SquidexClaimTypes.DisplayName, DisplayName));
            }

            if (!string.IsNullOrWhiteSpace(PictureUrl))
            {
                yield return(new Claim(SquidexClaimTypes.PictureUrl, PictureUrl));
            }

            if (Hidden.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.Hidden, Hidden.ToString()));
            }

            if (Invited.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.Invited, Invited.ToString()));
            }

            if (Consent.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.Consent, Consent.ToString()));
            }

            if (ConsentForEmails.HasValue)
            {
                yield return(new Claim(SquidexClaimTypes.ConsentForEmails, ConsentForEmails.ToString()));
            }

            if (Permissions != null)
            {
                if (!initial)
                {
                    yield return(new Claim(SquidexClaimTypes.Permissions, string.Empty));
                }

                foreach (var permission in Permissions)
                {
                    yield return(new Claim(SquidexClaimTypes.Permissions, permission.Id));
                }
            }
        }