fix 登录授权的问题
This commit is contained in:
@ -11,6 +11,9 @@ namespace QYZH.InteractiveMagazine.Infrastructure.Auth;
|
||||
/// </summary>
|
||||
public static class JwtHelper
|
||||
{
|
||||
public const string AdminTokenKeyPrefix = "InteractiveMagazine:AdminAuth:Token";
|
||||
public const string WeChatTokenKeyPrefix = "InteractiveMagazine:WeChatAuth:Token";
|
||||
|
||||
/// <summary>
|
||||
/// 生成JWT令牌(管理端 / 单用户场景)
|
||||
/// </summary>
|
||||
@ -60,6 +63,26 @@ public static class JwtHelper
|
||||
/// </summary>
|
||||
public const string WxUserIdClaimType = "WxUserId";
|
||||
|
||||
public static string BuildAdminTokenKey(string userId)
|
||||
{
|
||||
return $"{AdminTokenKeyPrefix}:{userId}";
|
||||
}
|
||||
|
||||
public static string BuildAdminTokenKey(long userId)
|
||||
{
|
||||
return BuildAdminTokenKey(userId.ToString());
|
||||
}
|
||||
|
||||
public static string BuildWeChatTokenKey(string wxUserId, string userId)
|
||||
{
|
||||
return $"{WeChatTokenKeyPrefix}:{wxUserId}:{userId}";
|
||||
}
|
||||
|
||||
public static string BuildWeChatTokenKey(long wxUserId, long userId)
|
||||
{
|
||||
return BuildWeChatTokenKey(wxUserId.ToString(), userId.ToString());
|
||||
}
|
||||
|
||||
private static string BuildToken(Claim[] claims, JwtSettings settings)
|
||||
{
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(settings.SecretKey!));
|
||||
|
||||
Reference in New Issue
Block a user