From ef6a6d94d109fe5bca1ab7969177ac3d7771ad4e Mon Sep 17 00:00:00 2001 From: yubaolee Date: Mon, 4 Jun 2018 14:31:08 +0800 Subject: [PATCH] routine update --- OpenAuth.Mvc/Controllers/BaseController.cs | 11 +++++++---- .../Areas/SSO/Controllers/CheckController.cs | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/OpenAuth.Mvc/Controllers/BaseController.cs b/OpenAuth.Mvc/Controllers/BaseController.cs index 7242067f..5e6e290e 100644 --- a/OpenAuth.Mvc/Controllers/BaseController.cs +++ b/OpenAuth.Mvc/Controllers/BaseController.cs @@ -32,7 +32,6 @@ namespace OpenAuth.Mvc.Controllers public class BaseController : SSOController { protected Response Result = new Response(); - protected ModuleView CurrentModule; protected string Controllername; //当前控制器小写名称 protected string Actionname; //当前Action小写名称 @@ -48,11 +47,15 @@ namespace OpenAuth.Mvc.Controllers var function = this.GetType().GetMethods().FirstOrDefault(u => u.Name.ToLower() == Actionname); if (function == null) throw new Exception("未能找到Action"); - + //权限验证标识 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标识 - if (authorize != null && CurrentModule == null) + if ( currentModule == null) { filterContext.Result = new RedirectResult("/Login/Index"); return; diff --git a/OpenAuth.WebApi/Areas/SSO/Controllers/CheckController.cs b/OpenAuth.WebApi/Areas/SSO/Controllers/CheckController.cs index 66f96956..2a33991a 100644 --- a/OpenAuth.WebApi/Areas/SSO/Controllers/CheckController.cs +++ b/OpenAuth.WebApi/Areas/SSO/Controllers/CheckController.cs @@ -10,6 +10,7 @@ // *********************************************************************** using System; +using System.Data.Entity.Core; using System.Web.Http; using Infrastructure; using Infrastructure.Cache; @@ -71,7 +72,9 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers catch (Exception ex) { 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;