哪一行源代码设置了"上下文"。Authentication.User"和"IsAuthenticated"属性



我阅读了asp.net卡塔纳项目的源代码。你能告诉我哪行源代码设置了"context.Authentication.User"one_answers"IsAuthenticated"属性吗?非常感谢!

我发现下面的代码:

public void AddUserIdentity(IIdentity identity)
    {
        if (identity == null)
        {
            throw new ArgumentNullException("identity");
        }
        var newClaimsPrincipal = new ClaimsPrincipal(identity);
        IPrincipal existingPrincipal = _context.Request.User;
        if (existingPrincipal != null)
        {
            var existingClaimsPrincipal = existingPrincipal as ClaimsPrincipal;
            if (existingClaimsPrincipal == null)
            {
                IIdentity existingIdentity = existingPrincipal.Identity;
                if (existingIdentity.IsAuthenticated)
                {
                    newClaimsPrincipal.AddIdentity(existingIdentity as ClaimsIdentity ?? new ClaimsIdentity(existingIdentity));
                }
            }
            else
            {
                foreach (var existingClaimsIdentity in existingClaimsPrincipal.Identities)
                {
                    if (existingClaimsIdentity.IsAuthenticated)
                    {
                        newClaimsPrincipal.AddIdentity(existingClaimsIdentity);
                    }
                }
            }
        }
        _context.Request.User = newClaimsPrincipal;
    }

最新更新