public RenderPartialExpression <TViewModel> RequiresAccessTo(params string[] roles) { if (_isAuthorized) { _isAuthorized = PrincipalRoles.IsInRole(roles); } return(this); }
public void read_role_off_principal() { var principal = new GenericPrincipal(new GenericIdentity("somebody"), new string[] { "a", "b" }); Thread.CurrentPrincipal = principal; PrincipalRoles.Current.ShouldBeTheSameAs(principal); PrincipalRoles.IsInRole("a").ShouldBeTrue(); PrincipalRoles.IsInRole("c").ShouldBeFalse(); }
public FormLineExpression <T> EditableForRole(params string[] roles) { return(Editable(PrincipalRoles.IsInRole(roles))); }
// TODO -- will need something more generic later. Maybe. public ExtensionsExpression OnlyForRoles(params string[] roles) { Func <bool> filter = () => PrincipalRoles.IsInRole(roles); return(register(g => g.FilterLast(filter))); }
public static HtmlTag RequiresAccessTo(this HtmlTag tag, params string[] roleName) { return(tag.Authorized(tag.Authorized() && PrincipalRoles.IsInRole(roleName))); }
public static bool CanView(Type type) { return(PrincipalRoles.IsInRole(SecurableNameForViewing(type))); }
public static bool CanCreate(Type type) { return(PrincipalRoles.IsInRole(SecurableNameForCreation(type))); }