This commit is contained in:
mtvpls
2026-01-25 17:23:49 +08:00
parent 29781d9d5a
commit e6db59a16d
2 changed files with 10 additions and 10 deletions

View File

@@ -43,14 +43,6 @@ export async function refreshAccessToken(
}
const now = Date.now();
const authData = {
username,
role,
timestamp: now, // 新的 Access Token 时间戳
tokenId,
refreshToken,
refreshExpires
};
// 生成新的签名
const dataToSign = JSON.stringify({
@@ -64,7 +56,15 @@ export async function refreshAccessToken(
process.env.PASSWORD || ''
);
authData.signature = signature;
const authData = {
username,
role,
timestamp: now, // 新的 Access Token 时间戳
tokenId,
refreshToken,
refreshExpires,
signature
};
console.log(`Refreshed access token for ${username}`);

View File

@@ -39,7 +39,7 @@ export async function middleware(request: NextRequest) {
// 其他模式:验证签名和时间戳,支持自动续期
// 检查是否有用户名非localStorage模式下密码不存储在cookie中
if (!authInfo.username || !authInfo.signature || !authInfo.timestamp) {
if (!authInfo.username || !authInfo.role || !authInfo.signature || !authInfo.timestamp) {
return handleAuthFailure(request, pathname);
}