mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 05:13:25 +08:00
增加权限错误页面
This commit is contained in:
parent
2b357fbd6b
commit
87712e2b49
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
17
OpenAuth.Mvc/Controllers/ErrorController.cs
Normal file
17
OpenAuth.Mvc/Controllers/ErrorController.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "全部机构",
|
||||
Name = "根结点",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
|
@ -125,6 +125,7 @@
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="AutofacExt.cs" />
|
||||
<Compile Include="Controllers\BaseController.cs" />
|
||||
<Compile Include="Controllers\ErrorController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\LoginController.cs" />
|
||||
<Compile Include="Controllers\ModuleManagerController.cs" />
|
||||
@ -552,6 +553,7 @@
|
||||
<Content Include="BJUI\themes\purple\zTreeStandard.png" />
|
||||
<Content Include="favicon.ico" />
|
||||
<Content Include="Global.asax" />
|
||||
<None Include="Views\Error\NoAccess.cshtml" />
|
||||
<None Include="Views\Home\git.cshtml" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Web.Debug.config">
|
||||
|
38
OpenAuth.Mvc/Views/Error/NoAccess.cshtml
Normal file
38
OpenAuth.Mvc/Views/Error/NoAccess.cshtml
Normal file
@ -0,0 +1,38 @@
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
<div class="bjui-pageHeader" style="background:#FFF;">
|
||||
<div style="padding: 0 15px;">
|
||||
<h4 style="margin-bottom:20px;">
|
||||
您无权访问该页面
|
||||
</h4>
|
||||
|
||||
|
||||
<div class="row" style=" margin-top:10px;">
|
||||
<div class="col-md-6" style="padding:5px;">
|
||||
<div class="alert alert-info" role="alert" style="margin:0 0 5px; padding:5px 15px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageContent">
|
||||
<div style="margin-top:5px; margin-right:300px; overflow:hidden;">
|
||||
<div class="row" style="padding: 0 8px;">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><h3 class="panel-title">OpenAuth.Net/GIT</h3></div>
|
||||
|
||||
<div class="panel-body">
|
||||
<iframe width="100%" height="240" class="share_self" frameborder="0" scrolling="no" src="/Home/Git"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -26,9 +26,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageContent">
|
||||
<div style="position:absolute;top:15px;right:0;width:300px;">
|
||||
<iframe width="100%" height="550" class="share_self" frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=550&fansRow=2&ptype=1&speed=0&skin=1&isTitle=1&noborder=1&isWeibo=1&isFans=0&uid=2838273614&verifier=75a3b95b&dpc=1"></iframe>
|
||||
</div>
|
||||
<div style="margin-top:5px; margin-right:300px; overflow:hidden;">
|
||||
<div class="row" style="padding: 0 8px;">
|
||||
<div class="col-md-12">
|
||||
|
Loading…
Reference in New Issue
Block a user