using Bootstrap.DataAccess; using Longbow.Web.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; namespace Bootstrap.Admin { /// /// /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] class BAAuthorizeAttribute : LgbAuthorizeAttribute { /// /// /// /// /// protected override IEnumerable RetrieveRolesByUserName(string userName) { return RoleHelper.RetrieveRolesByUserName(userName).Select(r => r.RoleName); } /// /// /// /// /// protected override IEnumerable RetrieveRolesByUrl(string url) { return RoleHelper.RetrieveRolesByUrl(url).Select(r => r.RoleName); } /// /// /// /// protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext) { if (!filterContext.HttpContext.User.Identity.IsAuthenticated) { base.HandleUnauthorizedRequest(filterContext); return; } var view = new ViewResult(); view.ViewName = "UnAuthorized"; filterContext.Result = view; } } }