修改BUG:api认证没有对令牌进行替换

This commit is contained in:
Argo-Lenovo 2016-11-17 18:47:39 +08:00
parent ae0be5afb1
commit 038c84e332
1 changed files with 5 additions and 2 deletions

View File

@ -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
{
/// <summary>
@ -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);
}