修改问题

This commit is contained in:
zpc 2024-09-03 22:10:55 +08:00
parent 925a58ca34
commit bef6e53819

View File

@ -238,23 +238,33 @@ namespace HuanMeng.MiaoYu.Code.Base
}
if (!string.IsNullOrEmpty(accessToken))
{
var (principal, jwtToken) = JwtAuthManager.DecodeJwtToken(accessToken);
if (jwtToken == null)//|| !jwtToken.Header.Alg.Equals(SecurityAlgorithms.HmacSha256Signature)
try
{
throw new SecurityTokenException("无效的token");
var (principal, jwtToken) = JwtAuthManager.DecodeJwtToken(accessToken);
if (jwtToken == null)//|| !jwtToken.Header.Alg.Equals(SecurityAlgorithms.HmacSha256Signature)
{
throw new SecurityTokenException("无效的token");
}
var userIdStr = principal.FindFirst("UserId")?.Value;
if (string.IsNullOrEmpty(userIdStr))
{
throw new SecurityTokenException("无效的token");
}
var nickName = principal.FindFirst("NickName")?.Value;
var userId = int.Parse(userIdStr);
this._userInfo = new RequestUserInfo()
{
UserId = userId,
NickName = nickName
};
}
var userIdStr = principal.FindFirst("UserId")?.Value;
if (string.IsNullOrEmpty(userIdStr))
catch (Exception)
{
throw new SecurityTokenException("无效的token");
_userInfo = new RequestUserInfo()
{
UserId = 0
};
}
var nickName = principal.FindFirst("NickName")?.Value;
var userId = int.Parse(userIdStr);
this._userInfo = new RequestUserInfo()
{
UserId = userId,
NickName = nickName
};
}
else
{