Compare commits
No commits in common. "cd4bf087a23ca517f38d7e5e16f4d9968e1facde" and "a25722b88bab5746c5dae0ffd1a5125f56479f5b" have entirely different histories.
cd4bf087a2
...
a25722b88b
|
|
@ -77,9 +77,7 @@ namespace Learn.Archives.API.Controllers
|
||||||
[
|
[
|
||||||
new Claim(ClaimEnum.UserCenterRole,"1"),//让所有用户都有用户中心操作权限
|
new Claim(ClaimEnum.UserCenterRole,"1"),//让所有用户都有用户中心操作权限
|
||||||
new Claim(ClaimEnum.Role,admin.RoleId.ToString()),
|
new Claim(ClaimEnum.Role,admin.RoleId.ToString()),
|
||||||
new Claim(ClaimEnum.UserId,admin.Id.ToString()),
|
new Claim(ClaimEnum.UserId,admin.RoleId.ToString()),
|
||||||
new Claim(ClaimEnum.UserId,admin.Id.ToString()),
|
|
||||||
new Claim(ClaimEnum.Scope,"档案系统"),
|
|
||||||
new Claim(ClaimEnum.Id, admin.Id.ToString()),
|
new Claim(ClaimEnum.Id, admin.Id.ToString()),
|
||||||
new Claim(ClaimEnum.Name, admin.Name),
|
new Claim(ClaimEnum.Name, admin.Name),
|
||||||
])
|
])
|
||||||
|
|
@ -124,7 +122,7 @@ namespace Learn.Archives.API.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导入用户信息
|
/// 导入考试信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost, ResultIgnore]
|
[HttpPost, ResultIgnore]
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ using Learn.Archives.Core.Common;
|
||||||
using Learn.Archives.Core.Model.Dto;
|
using Learn.Archives.Core.Model.Dto;
|
||||||
using Learn.Archives.Core.Model;
|
using Learn.Archives.Core.Model;
|
||||||
using SqlSugar.IOC;
|
using SqlSugar.IOC;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
namespace Learn.Archives.API.Expand
|
namespace Learn.Archives.API.Expand
|
||||||
{
|
{
|
||||||
|
|
@ -204,7 +204,7 @@ namespace Learn.Archives.API.Expand
|
||||||
Url = context.Request.Path + context.Request.QueryString,
|
Url = context.Request.Path + context.Request.QueryString,
|
||||||
Method = context.Request.Method,
|
Method = context.Request.Method,
|
||||||
Request = request,
|
Request = request,
|
||||||
IP = $"{userInfo.Scope} {context.Connection?.RemoteIpAddress?.ToString()}",
|
IP = context.Connection?.RemoteIpAddress?.ToString(),
|
||||||
ResponseCode = result?.Code ?? -1,
|
ResponseCode = result?.Code ?? -1,
|
||||||
Response = (result != null ? JsonSerializer.Serialize(result) : null) ,
|
Response = (result != null ? JsonSerializer.Serialize(result) : null) ,
|
||||||
Authorization = context.Request.Headers.ContainsKey("Authorization")
|
Authorization = context.Request.Headers.ContainsKey("Authorization")
|
||||||
|
|
@ -220,15 +220,6 @@ namespace Learn.Archives.API.Expand
|
||||||
|
|
||||||
public override async void OnActionExecuting(ActionExecutingContext context)
|
public override async void OnActionExecuting(ActionExecutingContext context)
|
||||||
{
|
{
|
||||||
// 直接返回原始结果,不封装
|
|
||||||
if (context.HttpContext.GetEndpoint()?
|
|
||||||
.Metadata.GetMetadata<IAllowAnonymous>() is null
|
|
||||||
&& string.IsNullOrEmpty(userInfo.Scope))
|
|
||||||
{
|
|
||||||
//过期的
|
|
||||||
context.Result = new UnauthorizedResult();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Executing400(context);
|
Executing400(context);
|
||||||
|
|
@ -250,6 +241,7 @@ namespace Learn.Archives.API.Expand
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
//添加http请求日志
|
||||||
|
|
||||||
base.OnActionExecuted(context);
|
base.OnActionExecuted(context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,5 @@ namespace Learn.Archives.Core.Common
|
||||||
{
|
{
|
||||||
get => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimEnum.Name)?.Value??string.Empty;
|
get => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimEnum.Name)?.Value??string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Scope
|
|
||||||
/// </summary>
|
|
||||||
public string Scope
|
|
||||||
{
|
|
||||||
get => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimEnum.Scope)?.Value ?? string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,16 +41,6 @@ namespace Learn.Archives.Core.Common
|
||||||
{
|
{
|
||||||
throw new OhException(message, code);
|
throw new OhException(message, code);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 抛出 模型校验异常
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <param name="code"></param>
|
|
||||||
/// <exception cref="OhException"></exception>
|
|
||||||
public static void ToeknError(string message, int code = 401)
|
|
||||||
{
|
|
||||||
throw new OhException(message, code);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public class OhException : Exception
|
public class OhException : Exception
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue