Created
April 24, 2014 09:32
-
-
Save jellebens/11248191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Security.Claims; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace JelleBens.Common.Security | |
{ | |
public class MyPrincipal : ClaimsPrincipal | |
{ | |
private MyPrincipal(ClaimsPrincipal principal) : base(principal) { } | |
public new static MyPrincipal Current | |
{ | |
get | |
{ | |
return new MyPrincipal(ClaimsPrincipal.Current); | |
} | |
} | |
public string DisplayName | |
{ | |
get | |
{ | |
string value = string.Empty; | |
this.TryGet(ClaimTypes.Name, out value); | |
return value; | |
} | |
set | |
{ | |
this.RefreshClaim(ClaimTypes.Name, value); | |
} | |
} | |
public string Email | |
{ | |
get | |
{ | |
string value = string.Empty; | |
this.TryGet(ClaimTypes.Email, out value); | |
return value; | |
} | |
set | |
{ | |
this.RefreshClaim(ClaimTypes.Email, value); | |
} | |
} | |
public bool IsAuthenticated | |
{ | |
get | |
{ | |
return this.Identity != null && this.Identity.IsAuthenticated; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment