routine update

This commit is contained in:
yubaolee 2018-06-04 14:31:08 +08:00
parent 84ce9e575a
commit ef6a6d94d1
2 changed files with 11 additions and 5 deletions

View File

@ -32,7 +32,6 @@ namespace OpenAuth.Mvc.Controllers
public class BaseController : SSOController public class BaseController : SSOController
{ {
protected Response Result = new Response(); protected Response Result = new Response();
protected ModuleView CurrentModule;
protected string Controllername; //当前控制器小写名称 protected string Controllername; //当前控制器小写名称
protected string Actionname; //当前Action小写名称 protected string Actionname; //当前Action小写名称
@ -48,11 +47,15 @@ namespace OpenAuth.Mvc.Controllers
var function = this.GetType().GetMethods().FirstOrDefault(u => u.Name.ToLower() == Actionname); var function = this.GetType().GetMethods().FirstOrDefault(u => u.Name.ToLower() == Actionname);
if (function == null) if (function == null)
throw new Exception("未能找到Action"); throw new Exception("未能找到Action");
//权限验证标识
var authorize = function.GetCustomAttribute(typeof(AuthenticateAttribute)); var authorize = function.GetCustomAttribute(typeof(AuthenticateAttribute));
CurrentModule = AuthUtil.GetCurrentUser().Modules.FirstOrDefault(u => u.Url.ToLower().Contains(Controllername)); if (authorize == null)
{
return;
}
var currentModule = AuthUtil.GetCurrentUser().Modules.FirstOrDefault(u => u.Url.ToLower().Contains(Controllername));
//当前登录用户没有Action记录&&Action有authenticate标识 //当前登录用户没有Action记录&&Action有authenticate标识
if (authorize != null && CurrentModule == null) if ( currentModule == null)
{ {
filterContext.Result = new RedirectResult("/Login/Index"); filterContext.Result = new RedirectResult("/Login/Index");
return; return;

View File

@ -10,6 +10,7 @@
// *********************************************************************** // ***********************************************************************
using System; using System;
using System.Data.Entity.Core;
using System.Web.Http; using System.Web.Http;
using Infrastructure; using Infrastructure;
using Infrastructure.Cache; using Infrastructure.Cache;
@ -71,7 +72,9 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
catch (Exception ex) catch (Exception ex)
{ {
result.Code = 500; result.Code = 500;
result.Message ="OpenAuth.WebAPI数据库访问失败:" + ex.Message; result.Message = ex.InnerException != null
? "OpenAuth.WebAPI数据库访问失败:" + ex.InnerException.Message
: "OpenAuth.WebAPI数据库访问失败:" + ex.Message;
} }
return result; return result;