初始化项目
This commit is contained in:
41
AUTS.Web/App_Start/Handler/HandlerAuthorizeAttribute.cs
Normal file
41
AUTS.Web/App_Start/Handler/HandlerAuthorizeAttribute.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace AUTS.Web
|
||||
{
|
||||
public class HandlerAuthorizeAttribute : ActionFilterAttribute
|
||||
{
|
||||
public bool Ignore { get; set; }
|
||||
public HandlerAuthorizeAttribute(bool ignore = true)
|
||||
{
|
||||
Ignore = ignore;
|
||||
}
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
var model = Services.UserLoginHelper.CurrentUser();
|
||||
|
||||
if (!(model.IsAdmin))
|
||||
{
|
||||
|
||||
//StringBuilder sbScript = new StringBuilder();
|
||||
//sbScript.Append("<script type='text/javascript'>alert('很抱歉!您的权限不足,访问被拒绝!');</script>");
|
||||
//filterContext.Result = new ContentResult() { Content = sbScript.ToString() };
|
||||
|
||||
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
|
||||
{
|
||||
controller = "Home",
|
||||
action = "NoAuthority"
|
||||
}));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user