+12
-12
@@ -64,8 +64,8 @@ export function isPasswordValid(password: string): boolean {
|
||||
return timingSafeEqual(provided, expected);
|
||||
}
|
||||
|
||||
export function setAdminSessionCookie(): void {
|
||||
const store = cookies();
|
||||
export async function setAdminSessionCookie(): Promise<void> {
|
||||
const store = await cookies();
|
||||
store.set(ADMIN_SESSION_COOKIE, buildToken(), {
|
||||
httpOnly: true,
|
||||
sameSite: "lax",
|
||||
@@ -75,8 +75,8 @@ export function setAdminSessionCookie(): void {
|
||||
});
|
||||
}
|
||||
|
||||
export function clearAdminSessionCookie(): void {
|
||||
const store = cookies();
|
||||
export async function clearAdminSessionCookie(): Promise<void> {
|
||||
const store = await cookies();
|
||||
store.set(ADMIN_SESSION_COOKIE, "", {
|
||||
httpOnly: true,
|
||||
sameSite: "lax",
|
||||
@@ -108,8 +108,8 @@ function parseFailState(rawValue: string | undefined): FailState {
|
||||
}
|
||||
}
|
||||
|
||||
export function getAdminLockState(): { locked: boolean; remainingSeconds: number } {
|
||||
const store = cookies();
|
||||
export async function getAdminLockState(): Promise<{ locked: boolean; remainingSeconds: number }> {
|
||||
const store = await cookies();
|
||||
const state = parseFailState(store.get(ADMIN_FAIL_COOKIE)?.value);
|
||||
const now = Date.now();
|
||||
|
||||
@@ -123,8 +123,8 @@ export function getAdminLockState(): { locked: boolean; remainingSeconds: number
|
||||
return { locked: false, remainingSeconds: 0 };
|
||||
}
|
||||
|
||||
export function registerFailedAdminAttempt(): { locked: boolean; remainingSeconds: number } {
|
||||
const store = cookies();
|
||||
export async function registerFailedAdminAttempt(): Promise<{ locked: boolean; remainingSeconds: number }> {
|
||||
const store = await cookies();
|
||||
const now = Date.now();
|
||||
const current = parseFailState(store.get(ADMIN_FAIL_COOKIE)?.value);
|
||||
const attempts = current.lockUntil > now ? current.attempts : current.attempts + 1;
|
||||
@@ -145,8 +145,8 @@ export function registerFailedAdminAttempt(): { locked: boolean; remainingSecond
|
||||
};
|
||||
}
|
||||
|
||||
export function resetAdminFailedAttempts(): void {
|
||||
const store = cookies();
|
||||
export async function resetAdminFailedAttempts(): Promise<void> {
|
||||
const store = await cookies();
|
||||
store.set(ADMIN_FAIL_COOKIE, "", {
|
||||
httpOnly: true,
|
||||
sameSite: "lax",
|
||||
@@ -156,12 +156,12 @@ export function resetAdminFailedAttempts(): void {
|
||||
});
|
||||
}
|
||||
|
||||
export function isAdminAuthenticated(): boolean {
|
||||
export async function isAdminAuthenticated(): Promise<boolean> {
|
||||
if (!isAdminAuthConfigured()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const store = cookies();
|
||||
const store = await cookies();
|
||||
const token = store.get(ADMIN_SESSION_COOKIE)?.value;
|
||||
|
||||
if (!token) {
|
||||
|
||||
Reference in New Issue
Block a user