mirror of
https://github.com/anjoy8/Blog.Core.git
synced 2024-09-20 23:48:27 +08:00
feat: 💯 change ClaimTypes.Role
This commit is contained in:
parent
5f132f0386
commit
5e4987d2f6
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Blog.Core.Controllers
|
||||
{
|
||||
|
@ -348,10 +349,16 @@ namespace Blog.Core.Controllers
|
|||
uidInHttpcontext1 = (from item in _httpContext.HttpContext.User.Claims
|
||||
where item.Type == "sub"
|
||||
select item.Value).FirstOrDefault().ObjToLong();
|
||||
roleIds = (from item in _httpContext.HttpContext.User.Claims
|
||||
where item.Type == ClaimTypes.Role
|
||||
select item.Value.ObjToLong()).ToList();
|
||||
if (!roleIds.Any())
|
||||
{
|
||||
roleIds = (from item in _httpContext.HttpContext.User.Claims
|
||||
where item.Type == "role"
|
||||
select item.Value.ObjToLong()).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// jwt
|
||||
|
@ -439,10 +446,16 @@ namespace Blog.Core.Controllers
|
|||
uidInHttpcontext1 = (from item in _httpContext.HttpContext.User.Claims
|
||||
where item.Type == "sub"
|
||||
select item.Value).FirstOrDefault().ObjToLong();
|
||||
roleIds = (from item in _httpContext.HttpContext.User.Claims
|
||||
where item.Type == ClaimTypes.Role
|
||||
select item.Value.ObjToLong()).ToList();
|
||||
if (!roleIds.Any())
|
||||
{
|
||||
roleIds = (from item in _httpContext.HttpContext.User.Claims
|
||||
where item.Type == "role"
|
||||
select item.Value.ObjToLong()).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// jwt
|
||||
|
|
|
@ -111,9 +111,9 @@
|
|||
</svg>
|
||||
<div id="swagger-ui"></div>
|
||||
<div id="footer" style="text-align: center;margin-bottom: 10px;">
|
||||
Copyright © 2018-2020 老张的哲学
|
||||
Copyright © 2018-2023 BCVP开发者社区
|
||||
|
||||
<br><span id="poweredby">Powered by .NET 5.0.0 on Docker & CentOS 7.6</span>
|
||||
<br><span id="poweredby">Powered by .NET 8.0 on Docker & CentOS 7.6</span>
|
||||
</div>
|
||||
<!-- Workaround for https://github.com/swagger-api/swagger-editor/issues/1371 -->
|
||||
<script>
|
||||
|
|
|
@ -208,21 +208,15 @@ namespace Blog.Core.AuthHelper
|
|||
|
||||
// 获取当前用户的角色信息
|
||||
var currentUserRoles = new List<string>();
|
||||
// ids4和jwt切换
|
||||
// ids4
|
||||
if (Permissions.IsUseIds4)
|
||||
currentUserRoles = (from item in httpContext.User.Claims
|
||||
where item.Type == ClaimTypes.Role
|
||||
select item.Value).ToList();
|
||||
if (!currentUserRoles.Any())
|
||||
{
|
||||
currentUserRoles = (from item in httpContext.User.Claims
|
||||
where item.Type == "role"
|
||||
select item.Value).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
// jwt
|
||||
currentUserRoles = (from item in httpContext.User.Claims
|
||||
where item.Type == requirement.ClaimType
|
||||
select item.Value).ToList();
|
||||
}
|
||||
|
||||
//超级管理员 默认拥有所有权限
|
||||
if (currentUserRoles.All(s => s != "SuperAdmin"))
|
||||
|
|
|
@ -4,7 +4,7 @@ using SqlSugar;
|
|||
namespace Blog.Core.Model.Logs;
|
||||
|
||||
[Tenant("log")]
|
||||
[SplitTable(SplitType.Month)] //按年分表 (自带分表支持 年、季、月、周、日)
|
||||
[SplitTable(SplitType.Month)] //按月分表 (自带分表支持 年、季、月、周、日)
|
||||
[SugarTable($@"{nameof(AuditSqlLog)}_{{year}}{{month}}{{day}}")]
|
||||
public class AuditSqlLog: BaseLog
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using SqlSugar;
|
|||
namespace Blog.Core.Model.Logs;
|
||||
|
||||
[Tenant("log")]
|
||||
[SplitTable(SplitType.Month)] //按年分表 (自带分表支持 年、季、月、周、日)
|
||||
[SplitTable(SplitType.Month)] //按月分表 (自带分表支持 年、季、月、周、日)
|
||||
[SugarTable($@"{nameof(GlobalErrorLog)}_{{year}}{{month}}{{day}}")]
|
||||
public class GlobalErrorLog : BaseLog
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using SqlSugar;
|
|||
namespace Blog.Core.Model.Logs;
|
||||
|
||||
[Tenant("log")]
|
||||
[SplitTable(SplitType.Month)] //按年分表 (自带分表支持 年、季、月、周、日)
|
||||
[SplitTable(SplitType.Month)] //按月分表 (自带分表支持 年、季、月、周、日)
|
||||
[SugarTable($@"{nameof(GlobalInformationLog)}_{{year}}{{month}}{{day}}")]
|
||||
public class GlobalInformationLog : BaseLog
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using SqlSugar;
|
|||
namespace Blog.Core.Model.Logs;
|
||||
|
||||
[Tenant("log")]
|
||||
[SplitTable(SplitType.Month)] //按年分表 (自带分表支持 年、季、月、周、日)
|
||||
[SplitTable(SplitType.Month)] //按月分表 (自带分表支持 年、季、月、周、日)
|
||||
[SugarTable($@"{nameof(GlobalWarningLog)}_{{year}}{{month}}{{day}}")]
|
||||
public class GlobalWarningLog: BaseLog
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Blog.Core.Model.Models
|
||||
{
|
||||
[SplitTable(SplitType.Day)]//按年分表 (自带分表支持 年、季、月、周、日)
|
||||
[SplitTable(SplitType.Day)]//按天分表 (自带分表支持 年、季、月、周、日)
|
||||
[SugarTable("SplitDemo_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
||||
public class SplitDemo
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user