2 files changed
+2
-9
No files matched your search
@@ -35,7 +35,6 @@ describe("Manager session cookie", () => {
|
||||
expect.any(String),
|
||||
expect.objectContaining({ secure: false, path: "/" }),
|
||||
);
|
||||
expect(cookieSet).toHaveBeenCalledWith("nextchair_manager_session", "", { path: "/manager", maxAge: 0 });
|
||||
});
|
||||
|
||||
it("marks the cookie Secure for an HTTPS deployment", async () => {
|
||||
|
||||
@@ -25,11 +25,7 @@ export function authenticateManager(email: string, password: string) {
|
||||
export async function createManagerSession() {
|
||||
const config = getManagerConfig();
|
||||
const value = `${config.adminEmail.trim().toLowerCase()}.${Date.now()}`;
|
||||
const store = await cookies();
|
||||
// Remove sessions issued by older builds with Path=/manager. Browsers can
|
||||
// retain both cookies, and the stale one may be selected first on /manager.
|
||||
store.set(COOKIE_NAME, "", { path: "/manager", maxAge: 0 });
|
||||
store.set(COOKIE_NAME, `${value}.${signature(value, config.authSecret)}`, {
|
||||
(await cookies()).set(COOKIE_NAME, `${value}.${signature(value, config.authSecret)}`, {
|
||||
httpOnly: true,
|
||||
sameSite: "strict",
|
||||
secure: isSecureDeployment(),
|
||||
@@ -41,9 +37,7 @@ export async function createManagerSession() {
|
||||
}
|
||||
|
||||
export async function clearManagerSession() {
|
||||
const store = await cookies();
|
||||
store.delete(COOKIE_NAME);
|
||||
store.set(COOKIE_NAME, "", { path: "/manager", maxAge: 0 });
|
||||
(await cookies()).delete(COOKIE_NAME);
|
||||
}
|
||||
|
||||
export async function isManagerAuthenticated() {
|
||||
|
||||
Reference in new issue
Block a user