protected virtual bool HasModuleAccess() { if (SecurityLevel == SecurityAccessLevel.Anonymous) { return(true); } User = HttpContextSource.Current.Request.IsAuthenticated ? UserController.Instance.GetCurrentUserInfo() : new UserInfo(); ContextSecurity security = new ContextSecurity(_module); switch (SecurityLevel) { case SecurityAccessLevel.Authenticated: return(User.UserID != -1); case SecurityAccessLevel.Host: return(User.IsSuperUser); case SecurityAccessLevel.Admin: return(security.IsAdmin); case SecurityAccessLevel.Moderate: return(security.CanModerate); case SecurityAccessLevel.Comment: return(security.CanComment); case SecurityAccessLevel.Edit: return(security.CanEdit); case SecurityAccessLevel.View: return(security.CanView); } return(false); }
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.Moderate: return(security.CanModerate); case SecurityAccessLevel.Comment: return(security.CanComment); case SecurityAccessLevel.Edit: return(security.CanEdit); case SecurityAccessLevel.View: return(security.CanView); } return(false); }