mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-02 18:51:52 +02:00
🔥 Remove support for legacy sessions (#1654)
This commit is contained in:
parent
0bdceb7bbe
commit
13e078cb88
5 changed files with 0 additions and 219 deletions
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue