From 038c84e332b2a005b9deb5e74df14537602de993 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Thu, 17 Nov 2016 18:47:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9Aapi=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=B2=A1=E6=9C=89=E5=AF=B9=E4=BB=A4=E7=89=8C=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/App_Start/BAAPIAuthorizaAttribute.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Bootstrap.Admin/App_Start/BAAPIAuthorizaAttribute.cs b/Bootstrap.Admin/App_Start/BAAPIAuthorizaAttribute.cs index 58e4e658..71696b6d 100644 --- a/Bootstrap.Admin/App_Start/BAAPIAuthorizaAttribute.cs +++ b/Bootstrap.Admin/App_Start/BAAPIAuthorizaAttribute.cs @@ -1,9 +1,10 @@ -using Longbow.Security.Principal; +using Bootstrap.DataAccess; +using Longbow.Security.Principal; +using System.Linq; using System.Security.Principal; using System.Web.Http; using System.Web.Http.Controllers; - namespace Bootstrap.Admin { /// @@ -22,6 +23,8 @@ namespace Bootstrap.Admin if (principal.Identity.IsAuthenticated) { if (LgbPrincipal.IsAdmin(principal.Identity.Name)) return true; + var roles = RoleHelper.RetrieveRolesByUserName(principal.Identity.Name).Select(r => r.RoleName); + actionContext.ControllerContext.RequestContext.Principal = new LgbPrincipal(principal.Identity, roles); } return base.IsAuthorized(actionContext); }