using Microsoft.AspNetCore.Authentication.JwtBearer;
namespace Application.Web
{
///
/// JWT验证
///
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();
//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); // 自定义错误码:用户禁用
//}
}
}
}