Add GitHub Email information

Add information about GitHub email to the context
This commit is contained in:
Nikolay Belykh
2014-10-09 21:25:55 +02:00
parent 35e31b1731
commit 3fbdc04aaf
2 changed files with 10 additions and 0 deletions

View File

@@ -103,6 +103,10 @@ namespace Owin.Security.Providers.GitHub
{
context.Identity.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, context.UserName, XmlSchemaString, Options.AuthenticationType));
}
if (!string.IsNullOrEmpty(context.Email))
{
context.Identity.AddClaim(new Claim(ClaimTypes.Email, context.Email, XmlSchemaString, Options.AuthenticationType));
}
if (!string.IsNullOrEmpty(context.Name))
{
context.Identity.AddClaim(new Claim("urn:github:name", context.Name, XmlSchemaString, Options.AuthenticationType));

View File

@@ -31,6 +31,7 @@ namespace Owin.Security.Providers.GitHub
Name = TryGetValue(user, "name");
Link = TryGetValue(user, "url");
UserName = TryGetValue(user, "login");
Email = TryGetValue(user, "email");
}
/// <summary>
@@ -64,6 +65,11 @@ namespace Owin.Security.Providers.GitHub
/// </summary>
public string UserName { get; private set; }
/// <summary>
/// Gets the GitHub email
/// </summary>
public string Email { get; private set; }
/// <summary>
/// Gets the <see cref="ClaimsIdentity"/> representing the user
/// </summary>