diff --git a/src/app/auth/signup/page.tsx b/src/app/auth/signup/page.tsx
index 6e8036e6..94a88a06 100644
--- a/src/app/auth/signup/page.tsx
+++ b/src/app/auth/signup/page.tsx
@@ -2,7 +2,11 @@ import SignupForm from "@app/components/auth/SignupForm";
import { verifySession } from "@app/lib/auth/verifySession";
import { redirect } from "next/navigation";
-export default async function Page() {
+export default async function Page({
+ searchParams,
+}: {
+ searchParams: { [key: string]: string | string[] | undefined };
+}) {
const user = await verifySession();
if (user) {
@@ -11,7 +15,7 @@ export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/auth/verify-email/page.tsx b/src/app/auth/verify-email/page.tsx
index d409a56a..556dab11 100644
--- a/src/app/auth/verify-email/page.tsx
+++ b/src/app/auth/verify-email/page.tsx
@@ -2,7 +2,11 @@ import VerifyEmailForm from "@app/components/auth/VerifyEmailForm";
import { verifySession } from "@app/lib/auth/verifySession";
import { redirect } from "next/navigation";
-export default async function Page() {
+export default async function Page({
+ searchParams,
+}: {
+ searchParams: { [key: string]: string | string[] | undefined };
+}) {
const user = await verifySession();
if (!user) {
@@ -13,11 +17,12 @@ export default async function Page() {
redirect("/");
}
- console.log(user.email)
-
return (
<>
-
+
>
);
}
diff --git a/src/components/auth/LoginForm.tsx b/src/components/auth/LoginForm.tsx
index b978d7ba..319165db 100644
--- a/src/components/auth/LoginForm.tsx
+++ b/src/components/auth/LoginForm.tsx
@@ -70,12 +70,18 @@ export default function LoginForm({ redirect }: LoginFormProps) {
setError(null);
if (res.data?.data?.emailVerificationRequired) {
- router.push("/auth/verify-email");
+ if (redirect) {
+ router.push(`/auth/verify-email?redirect=${redirect}`);
+ } else {
+ router.push("/auth/verify-email");
+ }
return;
}
- if (redirect && typeof redirect === "string") {
+ if (redirect && redirect.includes("http")) {
window.location.href = redirect;
+ } else if (redirect) {
+ router.push(redirect);
} else {
router.push("/");
}
diff --git a/src/components/auth/SignupForm.tsx b/src/components/auth/SignupForm.tsx
index af477393..156ec595 100644
--- a/src/components/auth/SignupForm.tsx
+++ b/src/components/auth/SignupForm.tsx
@@ -75,16 +75,22 @@ export default function SignupForm({ redirect }: SignupFormProps) {
if (res && res.status === 200) {
setError(null);
- if (res.data.data.emailVerificationRequired) {
- router.push("/auth/verify-email");
+ if (res.data?.data?.emailVerificationRequired) {
+ if (redirect) {
+ router.push(`/auth/verify-email?redirect=${redirect}`);
+ } else {
+ router.push("/auth/verify-email");
+ }
return;
}
- if (redirect && typeof redirect === "string") {
+ if (redirect && redirect.includes("http")) {
window.location.href = redirect;
+ } else if (redirect) {
+ router.push(redirect);
+ } else {
+ router.push("/");
}
-
- router.push("/");
}
}
diff --git a/src/components/auth/VerifyEmailForm.tsx b/src/components/auth/VerifyEmailForm.tsx
index 976bf62c..3404294a 100644
--- a/src/components/auth/VerifyEmailForm.tsx
+++ b/src/components/auth/VerifyEmailForm.tsx
@@ -44,9 +44,13 @@ const FormSchema = z.object({
export type VerifyEmailFormProps = {
email: string;
+ redirect?: string;
};
-export default function VerifyEmailForm({ email }: VerifyEmailFormProps) {
+export default function VerifyEmailForm({
+ email,
+ redirect,
+}: VerifyEmailFormProps) {
const router = useRouter();
const [error, setError] = useState(null);
@@ -82,7 +86,14 @@ export default function VerifyEmailForm({ email }: VerifyEmailFormProps) {
"Email successfully verified! Redirecting you...",
);
setTimeout(() => {
- router.push("/");
+ if (redirect && redirect.includes("http")) {
+ window.location.href = redirect;
+ }
+ if (redirect) {
+ router.push(redirect);
+ } else {
+ router.push("/");
+ }
setIsSubmitting(false);
}, 3000);
}