创建项目

This commit is contained in:
Putoo
2026-04-21 16:54:18 +08:00
commit 6cdceccde7
59 changed files with 15320 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
namespace Application.Web
{
/// <summary>
/// JWT验证
/// </summary>
public class JwtHandle : IJwtValidator
{
public int Priority => 1;
public void ValidateAsync(TokenValidatedContext context, JwtTokenInfo tokenInfo)
{
string userId = StateHelper.userId;
if (string.IsNullOrEmpty(userId))
{
throw new JwtValidationException(
message: "未登录",
statusCode: 200,
errorCode: 401); // 自定义错误码:用户禁用
}
//var userService = App.GetService<IUnitUserService>();
//var userInfo = userService.GetUserInfoAsyc(userId);
//if (userInfo == null)
//{
// throw new JwtValidationException(
// message: "未登录",
// statusCode: 200,
// errorCode: 401); // 自定义错误码:用户禁用
//}
//if (userInfo.token != StateHelper.sid)
//{
// throw new JwtValidationException(
// message: "未登录",
// statusCode: 200,
// errorCode: 401); // 自定义错误码:用户禁用
//}
}
}
}