Revert "Update management-auth.ts"

This reverts commit a65360b82d.
This commit is contained in:
Stefan Lazic committed 2026-09-05 09:32:10 +01:00
1 parent 344c08b840
commit 3de53f0a67
1 file changed
+2 -20
+2 -20
View File
@@ -48,32 +48,14 @@ export async function clearManagerSession() {
export async function isManagerAuthenticated() { export async function isManagerAuthenticated() {
const config = getManagerConfig(); const config = getManagerConfig();
console.log("[manager-auth] auth secret:", config.authSecret ? "set" : "missing");
if (!config.authSecret) return false; if (!config.authSecret) return false;
const rawValue = (await cookies()).get(COOKIE_NAME)?.value;
const cookieStore = await cookies();
const rawValue = cookieStore.get(COOKIE_NAME)?.value;
console.log("[manager-auth] cookie:", rawValue ? "received" : "missing");
const value = rawValue ? decodeURIComponent(rawValue) : undefined; const value = rawValue ? decodeURIComponent(rawValue) : undefined;
if (!value) return false; if (!value) return false;
const separator = value.lastIndexOf("."); const separator = value.lastIndexOf(".");
if (separator < 1) return false; if (separator < 1) return false;
const payload = value.slice(0, separator); const payload = value.slice(0, separator);
const received = Buffer.from(value.slice(separator + 1)); const received = Buffer.from(value.slice(separator + 1));
const expected = Buffer.from(signature(payload, config.authSecret)); const expected = Buffer.from(signature(payload, config.authSecret));
return received.length === expected.length && timingSafeEqual(received, expected);
const valid =
received.length === expected.length &&
timingSafeEqual(received, expected);
console.log("[manager-auth] signature valid:", valid);
return valid;
} }