hard refresh on auth (#3305)

* hard refresh on auth

* k

* k

* comment for clarity
This commit is contained in:
pablodanswer
2024-12-02 12:12:12 -08:00
committed by GitHub
parent 5385bae100
commit edeaee93a2

View File

@@ -5,7 +5,6 @@ import { usePopup } from "@/components/admin/connectors/Popup";
import { basicLogin, basicSignup } from "@/lib/user";
import { Button } from "@/components/ui/button";
import { Form, Formik } from "formik";
import { useRouter } from "next/navigation";
import * as Yup from "yup";
import { requestEmailVerification } from "../lib";
import { useState } from "react";
@@ -22,10 +21,8 @@ export function EmailPasswordForm({
referralSource?: string;
nextUrl?: string | null;
}) {
const router = useRouter();
const { popup, setPopup } = usePopup();
const [isWorking, setIsWorking] = useState(false);
return (
<>
{isWorking && <Spinner />}
@@ -69,9 +66,13 @@ export function EmailPasswordForm({
if (loginResponse.ok) {
if (isSignup && shouldVerify) {
await requestEmailVerification(values.email);
router.push("/auth/waiting-on-verification");
// Use window.location.href to force a full page reload,
// ensuring app re-initializes with the new state (including
// server-side provider values)
window.location.href = "/auth/waiting-on-verification";
} else {
router.push(nextUrl ? encodeURI(nextUrl) : "/");
// See above comment
window.location.href = nextUrl ? encodeURI(nextUrl) : "/";
}
} else {
setIsWorking(false);