mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 14:04:41 +08:00
增加权限错误页面
This commit is contained in:
parent
2b357fbd6b
commit
87712e2b49
@ -12,29 +12,42 @@
|
|||||||
// <summary>基础控制器,设置权限</summary>
|
// <summary>基础控制器,设置权限</summary>
|
||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
|
|
||||||
using System.Web.Mvc;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Infrastructure.Helper;
|
using Infrastructure.Helper;
|
||||||
using OpenAuth.App.ViewModel;
|
using OpenAuth.App.ViewModel;
|
||||||
using OpenAuth.Domain;
|
|
||||||
using OpenAuth.Mvc.Models;
|
using OpenAuth.Mvc.Models;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
{
|
{
|
||||||
public class BaseController : Controller
|
public class BaseController : Controller
|
||||||
{
|
{
|
||||||
protected BjuiResponse BjuiResponse = new BjuiResponse();
|
protected BjuiResponse BjuiResponse = new BjuiResponse();
|
||||||
|
|
||||||
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||||
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
{
|
||||||
{
|
var loginUser = SessionHelper.GetSessionUser<LoginUserVM>();
|
||||||
base.OnActionExecuting(filterContext);
|
if (loginUser == null)
|
||||||
|
|
||||||
//#region 当Session过期自动跳出登录画面
|
|
||||||
if (SessionHelper.GetSessionUser<LoginUserVM>() == null)
|
|
||||||
{
|
{
|
||||||
Response.Redirect("/Login/Index");
|
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,
|
Id = 0,
|
||||||
ParentId = -1,
|
ParentId = -1,
|
||||||
Name = "全部机构",
|
Name = "根结点",
|
||||||
CascadeId = "0"
|
CascadeId = "0"
|
||||||
});
|
});
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
<Compile Include="App_Start\RouteConfig.cs" />
|
<Compile Include="App_Start\RouteConfig.cs" />
|
||||||
<Compile Include="AutofacExt.cs" />
|
<Compile Include="AutofacExt.cs" />
|
||||||
<Compile Include="Controllers\BaseController.cs" />
|
<Compile Include="Controllers\BaseController.cs" />
|
||||||
|
<Compile Include="Controllers\ErrorController.cs" />
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
<Compile Include="Controllers\LoginController.cs" />
|
<Compile Include="Controllers\LoginController.cs" />
|
||||||
<Compile Include="Controllers\ModuleManagerController.cs" />
|
<Compile Include="Controllers\ModuleManagerController.cs" />
|
||||||
@ -552,6 +553,7 @@
|
|||||||
<Content Include="BJUI\themes\purple\zTreeStandard.png" />
|
<Content Include="BJUI\themes\purple\zTreeStandard.png" />
|
||||||
<Content Include="favicon.ico" />
|
<Content Include="favicon.ico" />
|
||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
|
<None Include="Views\Error\NoAccess.cshtml" />
|
||||||
<None Include="Views\Home\git.cshtml" />
|
<None Include="Views\Home\git.cshtml" />
|
||||||
<Content Include="Web.config" />
|
<Content Include="Web.config" />
|
||||||
<Content Include="Web.Debug.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>
|
</div>
|
||||||
<div class="bjui-pageContent">
|
<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 style="margin-top:5px; margin-right:300px; overflow:hidden;">
|
||||||
<div class="row" style="padding: 0 8px;">
|
<div class="row" style="padding: 0 8px;">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
Loading…
Reference in New Issue
Block a user