|
|
@ -2,6 +2,7 @@
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
|
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
@ -25,14 +26,20 @@ namespace Myshipping.Core
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var httpContext = App.GetService<IHttpContextAccessor>().HttpContext;
|
|
|
|
var httpContext = App.GetService<IHttpContextAccessor>().HttpContext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var repTenant = App.GetService<SqlSugarRepository<SysTenant>>();
|
|
|
|
|
|
|
|
var repUser = App.GetService<SqlSugarRepository<SysUser>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tenant = repTenant.AsQueryable().Filter(null, true).First(x => x.Id == 142307070918780L);
|
|
|
|
|
|
|
|
var user = repUser.AsQueryable().Filter(null, true).First(x => x.Id == 142307070910551L);
|
|
|
|
|
|
|
|
|
|
|
|
ClaimsIdentity identity = new ClaimsIdentity("AuthenticationTypes.Federation");
|
|
|
|
ClaimsIdentity identity = new ClaimsIdentity("AuthenticationTypes.Federation");
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_USERID, value: "111"));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_USERID, value: user.Id.ToString()));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.TENANT_ID, value: "10"));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_ACCOUNT, value: user.Account));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_ACCOUNT, value: "admin"));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_NAME, value: user.Name));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_NAME, value: "管理员"));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_SUPERADMIN, value: ((int)user.AdminType).ToString()));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_SUPERADMIN, value: AdminType.Admin.ToString()));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_TENANT_TYPE, value: tenant.TenantType.ToString()));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.CLAINM_TENANT_TYPE, value: TenantTypeEnum.SYSTEM.ToString()));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.TENANT_ID, value: tenant.Id.ToString()));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.TENANT_NAME, value: "测试"));
|
|
|
|
identity.AddClaim(new Claim(type: ClaimConst.TENANT_NAME, value: tenant.Name));
|
|
|
|
ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(identity);
|
|
|
|
ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(identity);
|
|
|
|
httpContext.User = claimsPrincipal;
|
|
|
|
httpContext.User = claimsPrincipal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|