public override bool IsAuthorized(AuthFilterContext context)
 {
     if (SecurityLevel == SecurityAccessLevel.Anonymous)
     {
         return true;
     }
     User = HttpContextSource.Current.Request.IsAuthenticated ? UserController.Instance.GetCurrentUserInfo() : new UserInfo();
     ContextSecurity security = new ContextSecurity(context.ActionContext.Request.FindModuleInfo());
     switch (SecurityLevel)
     {
         case SecurityAccessLevel.Authenticated:
             return User.UserID != -1;
         case SecurityAccessLevel.Host:
             return User.IsSuperUser;
         case SecurityAccessLevel.Admin:
             return security.IsAdmin;
         case SecurityAccessLevel.Edit:
             return security.CanEdit;
         case SecurityAccessLevel.View:
             return security.CanView;
         case SecurityAccessLevel.Pilot:
             return security.IsPilot;
         case SecurityAccessLevel.Verifier:
             return security.IsVerifier;
     }
     return false;
 }
Exemplo n.º 2
0
        public override bool IsAuthorized(AuthFilterContext context)
        {
            if (SecurityLevel == SecurityAccessLevel.Anonymous)
            {
                return(true);
            }
            User = HttpContextSource.Current.Request.IsAuthenticated ? UserController.Instance.GetCurrentUserInfo() : new UserInfo();
            ContextSecurity security = new ContextSecurity(context.ActionContext.Request.FindModuleInfo());

            switch (SecurityLevel)
            {
            case SecurityAccessLevel.Authenticated:
                return(User.UserID != -1);

            case SecurityAccessLevel.Host:
                return(User.IsSuperUser);

            case SecurityAccessLevel.Admin:
                return(security.IsAdmin);

            case SecurityAccessLevel.Edit:
                return(security.CanEdit);

            case SecurityAccessLevel.View:
                return(security.CanView);

            case SecurityAccessLevel.Pilot:
                return(security.IsPilot);

            case SecurityAccessLevel.Verifier:
                return(security.IsVerifier);
            }
            return(false);
        }