增加权限错误页面

This commit is contained in:
yubaolee
2015-12-02 10:06:30 +08:00
parent 2b357fbd6b
commit 87712e2b49
6 changed files with 85 additions and 18 deletions

View File

@@ -12,29 +12,42 @@
// <summary>基础控制器,设置权限</summary>
// ***********************************************************************
using System.Web.Mvc;
using System;
using System.Linq;
using Infrastructure.Helper;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Mvc.Models;
using System.Web.Mvc;
namespace OpenAuth.Mvc.Controllers
{
public class BaseController : Controller
{
public class BaseController : Controller
{
protected BjuiResponse BjuiResponse = new BjuiResponse();
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
//#region 当Session过期自动跳出登录画面
if (SessionHelper.GetSessionUser<LoginUserVM>() == null)
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var loginUser = SessionHelper.GetSessionUser<LoginUserVM>();
if (loginUser == null)
{
Response.Redirect("/Login/Index");
return;
}
//#endregion
}
}
if (Request.Url != null)
{
string url = Request.Url.LocalPath;
if(url !="/"
&& !url.Contains("Main")
&& !url.Contains("Error")
&& !url.Contains("Git")
&& !loginUser.Modules.Any(u => url.Contains(u.Url)))
{
Response.Redirect("/Error/NoAccess");
return;
}
}
base.OnActionExecuting(filterContext);
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace OpenAuth.Mvc.Controllers
{
public class ErrorController : Controller
{
// GET: Error
public ActionResult NoAccess()
{
return View();
}
}
}

View File

@@ -82,7 +82,7 @@ namespace OpenAuth.Mvc.Controllers
{
Id = 0,
ParentId = -1,
Name = "全部机构",
Name = "根结点",
CascadeId = "0"
});
return JsonHelper.Instance.Serialize(orgs);