Compare commits
2 Commits
70d591f925
...
ca5bafff46
| Author | SHA1 | Date | |
|---|---|---|---|
| ca5bafff46 | |||
|
|
12dcf00d5f |
@@ -2,6 +2,7 @@ import LoginLayout from "@/features/login/components/layout";
|
|||||||
import LoginFlow from "@/features/login/components/login-flow";
|
import LoginFlow from "@/features/login/components/login-flow";
|
||||||
import { redirect, createFileRoute } from "@tanstack/react-router";
|
import { redirect, createFileRoute } from "@tanstack/react-router";
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
const loginSearchSchema = z.object({
|
const loginSearchSchema = z.object({
|
||||||
stage: z.enum(["code", "name"]).optional(),
|
stage: z.enum(["code", "name"]).optional(),
|
||||||
@@ -9,6 +10,36 @@ const loginSearchSchema = z.object({
|
|||||||
callback: z.string().optional(),
|
callback: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function LoginComponent() {
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
const accessTokenCookies = cookies.filter(c => c.trim().startsWith('sAccessToken='));
|
||||||
|
|
||||||
|
if (accessTokenCookies.length > 0) {
|
||||||
|
console.log('[Login] Clearing old SuperTokens cookies');
|
||||||
|
|
||||||
|
const cookieNames = ['sAccessToken', 'sRefreshToken', 'sIdRefreshToken', 'sFrontToken'];
|
||||||
|
const cookieDomain = (window as any).__COOKIE_DOMAIN__ || undefined;
|
||||||
|
|
||||||
|
cookieNames.forEach(name => {
|
||||||
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
||||||
|
|
||||||
|
if (cookieDomain) {
|
||||||
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=${cookieDomain}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LoginLayout>
|
||||||
|
<LoginFlow />
|
||||||
|
</LoginLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute("/login")({
|
export const Route = createFileRoute("/login")({
|
||||||
validateSearch: loginSearchSchema,
|
validateSearch: loginSearchSchema,
|
||||||
beforeLoad: async ({ context }) => {
|
beforeLoad: async ({ context }) => {
|
||||||
@@ -16,11 +47,5 @@ export const Route = createFileRoute("/login")({
|
|||||||
throw redirect({ to: "/" });
|
throw redirect({ to: "/" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
component: () => {
|
component: LoginComponent,
|
||||||
return (
|
|
||||||
<LoginLayout>
|
|
||||||
<LoginFlow />
|
|
||||||
</LoginLayout>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user