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); }
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 }); }
public static ChatUser GetUser(this IJabbrRepository repository, ClaimsPrincipal principal) { string identity = principal.GetClaimValue(ClaimTypes.NameIdentifier); string providerName = principal.GetIdentityProvider(); return repository.GetUserByIdentity(providerName, identity); }
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; }