Skip to content

Instantly share code, notes, and snippets.

@jellebens
Created April 24, 2014 09:32
Show Gist options
  • Save jellebens/11248191 to your computer and use it in GitHub Desktop.
Save jellebens/11248191 to your computer and use it in GitHub Desktop.
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