Update signup handling to manage verification link
cgen-0f806590b73048b2aa57cee7730db153
This commit is contained in:
parent
6ddd29bdbd
commit
6143c0f1b8
1 changed files with 26 additions and 6 deletions
|
|
@ -56,17 +56,33 @@ export default function Login() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isSignUp) {
|
if (isSignUp) {
|
||||||
await signUp(email, password, {
|
const result = await signUp(email, password, {
|
||||||
id: "",
|
id: "",
|
||||||
full_name: fullName,
|
full_name: fullName,
|
||||||
user_type: "game_developer",
|
user_type: "game_developer",
|
||||||
username: email.split("@")[0],
|
username: email.split("@")[0],
|
||||||
});
|
});
|
||||||
toastSuccess({
|
|
||||||
title: "Account created!",
|
if (result?.emailSent) {
|
||||||
description:
|
setManualVerificationLink(null);
|
||||||
"Please check your email to verify your account, then sign in.",
|
} else if (result?.verificationUrl) {
|
||||||
});
|
setManualVerificationLink(result.verificationUrl);
|
||||||
|
try {
|
||||||
|
await navigator.clipboard?.writeText(result.verificationUrl);
|
||||||
|
toastInfo({
|
||||||
|
title: "Verification link copied",
|
||||||
|
description:
|
||||||
|
"We copied the manual verification link to your clipboard. Paste it into your browser to finish signup.",
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
toastInfo({
|
||||||
|
title: "Manual verification required",
|
||||||
|
description:
|
||||||
|
"Copy the link shown in the banner to verify your account.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setIsSignUp(false);
|
setIsSignUp(false);
|
||||||
} else {
|
} else {
|
||||||
await signIn(email, password);
|
await signIn(email, password);
|
||||||
|
|
@ -74,6 +90,10 @@ export default function Login() {
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Authentication error:", error);
|
console.error("Authentication error:", error);
|
||||||
|
toastError({
|
||||||
|
title: "Authentication failed",
|
||||||
|
description: error?.message || "Something went wrong. Please try again.",
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue