2 files changed
+2
-9
No files matched your search
@@ -35,7 +35,6 @@ describe("Manager session cookie", () => {
|
|||||||
expect.any(String),
|
expect.any(String),
|
||||||
expect.objectContaining({ secure: false, path: "/" }),
|
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 () => {
|
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() {
|
export async function createManagerSession() {
|
||||||
const config = getManagerConfig();
|
const config = getManagerConfig();
|
||||||
const value = `${config.adminEmail.trim().toLowerCase()}.${Date.now()}`;
|
const value = `${config.adminEmail.trim().toLowerCase()}.${Date.now()}`;
|
||||||
const store = await cookies();
|
(await cookies()).set(COOKIE_NAME, `${value}.${signature(value, config.authSecret)}`, {
|
||||||
// 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)}`, {
|
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
sameSite: "strict",
|
sameSite: "strict",
|
||||||
secure: isSecureDeployment(),
|
secure: isSecureDeployment(),
|
||||||
@@ -41,9 +37,7 @@ export async function createManagerSession() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function clearManagerSession() {
|
export async function clearManagerSession() {
|
||||||
const store = await cookies();
|
(await cookies()).delete(COOKIE_NAME);
|
||||||
store.delete(COOKIE_NAME);
|
|
||||||
store.set(COOKIE_NAME, "", { path: "/manager", maxAge: 0 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isManagerAuthenticated() {
|
export async function isManagerAuthenticated() {
|
||||||
|
|||||||
Reference in new issue
Block a user