mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-03-13 09:37:28 +08:00
fix: middleware auth
This commit is contained in:
@@ -33,8 +33,8 @@ export async function middleware(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 其他模式:只验证签名
|
// 其他模式:只验证签名
|
||||||
// 检查是否有用户名和密码
|
// 检查是否有用户名(非localStorage模式下密码不存储在cookie中)
|
||||||
if (!authInfo.username || !authInfo.password) {
|
if (!authInfo.username || !authInfo.signature) {
|
||||||
return redirectToLogin(request, pathname);
|
return redirectToLogin(request, pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,10 +76,10 @@ async function verifySignature(
|
|||||||
['verify']
|
['verify']
|
||||||
);
|
);
|
||||||
|
|
||||||
// 将十六进制字符串转换为ArrayBuffer
|
// 将十六进制字符串转换为Uint8Array
|
||||||
const signatureBuffer = new Uint8Array(
|
const signatureBuffer = new Uint8Array(
|
||||||
signature.match(/.{1,2}/g)?.map((byte) => parseInt(byte, 16)) || []
|
signature.match(/.{1,2}/g)?.map((byte) => parseInt(byte, 16)) || []
|
||||||
).buffer;
|
);
|
||||||
|
|
||||||
// 验证签名
|
// 验证签名
|
||||||
return await crypto.subtle.verify(
|
return await crypto.subtle.verify(
|
||||||
|
|||||||
Reference in New Issue
Block a user