diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-13 23:08:50 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-13 23:08:50 +0900 |
| commit | 470b7235b80d082009ad350e2b33ef6637209e02 (patch) | |
| tree | 60ffe938a4051255ea0d6b35001be50c28b76497 /frontend/app/.server/session.ts | |
| parent | 482c3a52a0fcc5870a7db4a190475caf61b211a3 (diff) | |
| parent | 6c30f383a65cb000d66a85cadc96253ce7061942 (diff) | |
| download | phperkaigi-2026-albatross-470b7235b80d082009ad350e2b33ef6637209e02.tar.gz phperkaigi-2026-albatross-470b7235b80d082009ad350e2b33ef6637209e02.tar.zst phperkaigi-2026-albatross-470b7235b80d082009ad350e2b33ef6637209e02.zip | |
Merge branch 'feat/frontend-rearchitecture'
Diffstat (limited to 'frontend/app/.server/session.ts')
| -rw-r--r-- | frontend/app/.server/session.ts | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/frontend/app/.server/session.ts b/frontend/app/.server/session.ts deleted file mode 100644 index 0edcc35..0000000 --- a/frontend/app/.server/session.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { createCookieSessionStorage } from "react-router"; - -export const cookieOptions = { - sameSite: "lax" as const, - path: "/", - httpOnly: true, - secure: process.env.NODE_ENV === "production", - secrets: [process.env.ALBATROSS_COOKIE_SECRET ?? "local"], -}; - -const innerSessionStorage = createCookieSessionStorage({ - cookie: { - name: "albatross_session", - ...cookieOptions, - }, -}); -type InnerSessionStorage = typeof innerSessionStorage; - -// This class is used to recover from invalid sessions. -// It may occur if the session had been created before the authentication library was updated. -class RecoverableSessionStorage { - innerStorage: InnerSessionStorage; - - constructor(innerStorage: InnerSessionStorage) { - this.innerStorage = innerStorage; - } - - // If the session is invalid, return a new session. - // It may occur if the session had been created before the authentication library was updated. - getSession(...args: Parameters<InnerSessionStorage["getSession"]>) { - try { - return this.innerStorage.getSession(...args); - } catch (e) { - void e; - return this.innerStorage.getSession(); - } - } - - commitSession(...args: Parameters<InnerSessionStorage["commitSession"]>) { - return this.innerStorage.commitSession(...args); - } - - destroySession(...args: Parameters<InnerSessionStorage["destroySession"]>) { - return this.innerStorage.destroySession(...args); - } -} - -export const sessionStorage = new RecoverableSessionStorage( - innerSessionStorage, -); |
