예제 #1
0
 public RenderPartialExpression <TViewModel> RequiresAccessTo(params string[] roles)
 {
     if (_isAuthorized)
     {
         _isAuthorized = PrincipalRoles.IsInRole(roles);
     }
     return(this);
 }
예제 #2
0
        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();
        }
예제 #3
0
 public FormLineExpression <T> EditableForRole(params string[] roles)
 {
     return(Editable(PrincipalRoles.IsInRole(roles)));
 }
예제 #4
0
        // 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)));
        }
예제 #5
0
 public static HtmlTag RequiresAccessTo(this HtmlTag tag, params string[] roleName)
 {
     return(tag.Authorized(tag.Authorized() && PrincipalRoles.IsInRole(roleName)));
 }
예제 #6
0
 public static bool CanView(Type type)
 {
     return(PrincipalRoles.IsInRole(SecurableNameForViewing(type)));
 }
예제 #7
0
 public static bool CanCreate(Type type)
 {
     return(PrincipalRoles.IsInRole(SecurableNameForCreation(type)));
 }