🔥 Remove support for legacy sessions (#1654)

This commit is contained in:
Luke Vella 2025-03-31 15:54:21 +01:00 committed by GitHub
parent 0bdceb7bbe
commit 13e078cb88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 0 additions and 219 deletions

View file

@ -4,12 +4,6 @@ import NextAuth from "next-auth";
import { nextAuthConfig } from "@/next-auth.config";
import {
deleteLegacyCookie,
getLegacySession,
migrateLegacyJWT,
} from "../legacy/next-auth-cookie-migration";
const { auth } = NextAuth(nextAuthConfig);
export const withAuth = (
@ -24,20 +18,6 @@ export const withAuth = (
console.error(e);
}
let isLegacySession = false;
let isExpiredLegacySession = false;
if (!session) {
try {
session = await getLegacySession();
if (session) {
isLegacySession = true;
}
} catch {
isExpiredLegacySession = true;
}
}
try {
const res = await nextAuthConfig.callbacks.authorized({
request,
@ -55,20 +35,6 @@ export const withAuth = (
const middlewareRes = await middleware(request);
if (isLegacySession) {
console.warn("Found legacy session, migrating…");
try {
await migrateLegacyJWT(middlewareRes);
} catch (e) {
console.error(e);
}
}
if (isExpiredLegacySession) {
console.warn("Found expired legacy session, deleting…");
deleteLegacyCookie(middlewareRes);
}
return middlewareRes;
};
};