diff --git a/src/app/(auth)/signup/page.tsx b/src/app/(auth)/signup/page.tsx index 4e5f0d3c..b40e5b5a 100644 --- a/src/app/(auth)/signup/page.tsx +++ b/src/app/(auth)/signup/page.tsx @@ -17,6 +17,7 @@ export default function SignupPage() { const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); + const [awaitingConfirmation, setAwaitingConfirmation] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -43,6 +44,7 @@ export default function SignupPage() { email, password, options: { + emailRedirectTo: `${window.location.origin}/login`, data: { first_name: firstName, last_name: lastName, @@ -53,6 +55,11 @@ export default function SignupPage() { if (error) { setError(error.message); setIsLoading(false); + } else if (!data.session) { + // "Confirm email" is on: there is no session until the user clicks the link. + // The profile row is created by the handle_new_user trigger on auth.users. + setAwaitingConfirmation(true); + setIsLoading(false); } else { const user = data.user; if (user) { @@ -102,6 +109,20 @@ export default function SignupPage() {

+ {awaitingConfirmation ? ( +
+
+ Check your UCLA inbox to confirm your account. We sent a confirmation link to {email}. Once you've confirmed, log in to continue. +
+ + back to login + +
+ ) : ( + <> {/* Error Message */} {error && (
@@ -210,6 +231,8 @@ export default function SignupPage() { {isLoading ? "signing up..." : "sign up"} + + )}