try this
Some checks failed
CI/CD Pipeline / Build and Push App Docker Image (push) Failing after 17s
CI/CD Pipeline / Build and Push PocketBase Docker Image (push) Successful in 7s
CI/CD Pipeline / Deploy to Kubernetes (push) Has been skipped

This commit is contained in:
yohlo
2026-03-03 08:42:47 -06:00
parent fda8751642
commit 12dcf00d5f

View File

@@ -2,6 +2,7 @@ import LoginLayout from "@/features/login/components/layout";
import LoginFlow from "@/features/login/components/login-flow";
import { redirect, createFileRoute } from "@tanstack/react-router";
import z from "zod";
import { useEffect } from "react";
const loginSearchSchema = z.object({
stage: z.enum(["code", "name"]).optional(),
@@ -9,6 +10,36 @@ const loginSearchSchema = z.object({
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")({
validateSearch: loginSearchSchema,
beforeLoad: async ({ context }) => {
@@ -16,11 +47,5 @@ export const Route = createFileRoute("/login")({
throw redirect({ to: "/" });
}
},
component: () => {
return (
<LoginLayout>
<LoginFlow />
</LoginLayout>
);
},
component: LoginComponent,
});