mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-05-09 15:18:00 +08:00
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : OpenAuth.Mvc
|
|
// Author : Administrator
|
|
// Created : 09-22-2015
|
|
//
|
|
// Last Modified By : Administrator
|
|
// Last Modified On : 09-22-2015
|
|
// ***********************************************************************
|
|
// <copyright file="BaseController.cs" company="">
|
|
// Copyright (c) . All rights reserved.
|
|
// </copyright>
|
|
// <summary>基础控制器,设置权限</summary>
|
|
// ***********************************************************************
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using Infrastructure.Helper;
|
|
using OpenAuth.App.ViewModel;
|
|
using OpenAuth.Mvc.Models;
|
|
using System.Web.Mvc;
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
{
|
|
public class BaseController : Controller
|
|
{
|
|
protected BjuiResponse BjuiResponse = new BjuiResponse();
|
|
|
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
{
|
|
var loginUser = SessionHelper.GetSessionUser<LoginUserVM>();
|
|
if (loginUser == null)
|
|
{
|
|
Response.Redirect("/Login/Index");
|
|
return;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
} |