Skip to content

Instantly share code, notes, and snippets.

@daanl
Created May 24, 2013 14:02
Show Gist options
  • Save daanl/5643746 to your computer and use it in GitHub Desktop.
Save daanl/5643746 to your computer and use it in GitHub Desktop.
public class User : IPrincipal
{
public User(string username, IEnumerable<string> roles)
{
Username = username;
Roles = roles;
}
public string Username { get; private set; }
public IEnumerable<string> Roles { get; private set; }
public bool IsInRole(string role)
{
return Roles.Any(x => x.Equals(role, StringComparison.InvariantCultureIgnoreCase));
}
public IIdentity Identity
{
get { return new GenericIdentity(Username);}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment