Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🧹 Remove support for legacy jwt (#996)
Luke Vellac185e73825b2
diff --git a/apps/web/src/app/guest.ts b/apps/web/src/app/guest.tsindex 3797feb0a..14ae378cb 100644--- a/apps/web/src/app/guest.ts+++ b/apps/web/src/app/guest.ts@@ -1,6 +1,4 @@import { randomid } from "@rallly/backend/utils/nanoid";-import type { TimeFormat } from "@rallly/database";-import { unsealData } from "iron-session/edge";import { NextRequest, NextResponse } from "next/server";import { encode, JWT } from "next-auth/jwt";@@ -52,10 +50,7 @@ export async function initGuest(req: NextRequest, res: NextResponse) {return;}- // TODO (Luke Vella) [2023-11-07]: Remove this after 30 days (Date: 2023-12-07)- const legacyJwt = await getLegacyToken(req, res);-- const jwt: JWT = legacyJwt || {+ const jwt: JWT = {sub: `user-${randomid()}`,email: null,};@@ -64,44 +59,3 @@ export async function initGuest(req: NextRequest, res: NextResponse) {return jwt;}--async function getLegacyToken(req: NextRequest, res: NextResponse) {- /**- * We moved from a bespoke session implementation to next-auth.- * This middleware looks for the old session cookie and moves it to- * a temporary cookie accessible to the client which will exchange it- * for a new session token with the legacy-token provider.- */- const legacyToken = req.cookies.get("rallly-session");- if (legacyToken) {- // delete old cookie- res.cookies.delete("rallly-session");-- // make sure old cookie isn't expired- const payload = await unsealData<{- user: {- id: string;- isGuest: boolean;- preferences?: {- weekStart?: number;- timeZone?: string;- timeFormat?: TimeFormat;- };- };- }>(legacyToken.value, {- password: process.env.SECRET_PASSWORD,- });- // if it's not expired, write it to a new cookie that we- // can read from the client- if (Object.keys(payload).length > 0 && payload?.user?.isGuest) {- const jwt: JWT = {- sub: payload.user.id,- email: null,- ...payload.user.preferences,- };-- return jwt;- }- }- return null;-}