本文整理汇总了C#中System.Security.Claims.ClaimsPrincipal.GetClaimValue方法的典型用法代码示例。如果您正苦于以下问题:C# ClaimsPrincipal.GetClaimValue方法的具体用法?C# ClaimsPrincipal.GetClaimValue怎么用?C# ClaimsPrincipal.GetClaimValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Claims.ClaimsPrincipal
的用法示例。
在下文中一共展示了ClaimsPrincipal.GetClaimValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUser
public ChatUser AddUser(ClaimsPrincipal claimsPrincipal)
{
var identity = claimsPrincipal.GetClaimValue(ClaimTypes.NameIdentifier);
var name = claimsPrincipal.GetClaimValue(ClaimTypes.Name);
var email = claimsPrincipal.GetClaimValue(ClaimTypes.Email);
var providerName = claimsPrincipal.GetIdentityProvider();
return AddUser(name, providerName, identity, email);
}
示例2: LinkIdentity
public void LinkIdentity(ChatUser user, ClaimsPrincipal claimsPrincipal)
{
var identity = claimsPrincipal.GetClaimValue(ClaimTypes.NameIdentifier);
var email = claimsPrincipal.GetClaimValue(ClaimTypes.Email);
var providerName = claimsPrincipal.GetIdentityProvider();
// Link this new identity
user.Identities.Add(new ChatUserIdentity
{
Email = email,
Identity = identity,
ProviderName = providerName
});
}
示例3: GetUser
public static ChatUser GetUser(this IJabbrRepository repository, ClaimsPrincipal principal)
{
string identity = principal.GetClaimValue(ClaimTypes.NameIdentifier);
string providerName = principal.GetIdentityProvider();
return repository.GetUserByIdentity(providerName, identity);
}
示例4: GetUser
private EmailUser GetUser(ClaimsPrincipal principal)
{
string identity = principal.GetClaimValue(ClaimTypes.NameIdentifier);
var providerName = principal.GetIdentityProvider();
var emailUserIdentity = _session.Query<EmailUserIdentity>().SingleOrDefault(u => u.Identity == identity && u.ProviderName == providerName);
return emailUserIdentity != null ? emailUserIdentity.User : null;
}