feat: Implement password reset flow

This commit is contained in:
gpt-engineer-app[bot]
2025-10-14 17:14:34 +00:00
parent e8a7c028e9
commit 70f94b8a30
4 changed files with 166 additions and 73 deletions

View File

@@ -140,24 +140,22 @@ export function SecurityTab() {
};
const handlePasswordSetupSuccess = (email?: string, needsConfirmation?: boolean) => {
if (email) {
// Password was set, user was logged out, needs to confirm email
if (needsConfirmation) {
toast({
title: 'Check Your Email',
description: 'A confirmation link has been sent to your email. Click it to activate password authentication, then sign in.',
duration: 10000,
});
} else {
toast({
title: 'Password Set Successfully',
description: 'Please sign in with your email and password to complete setup.',
duration: 6000,
});
}
if (email && needsConfirmation) {
// Password setup initiated via reset flow
toast({
title: 'Check Your Email',
description: "Click the password reset link from Supabase to complete setup. You'll receive two emails: one with the reset link, and one with instructions from ThrillWiki.",
duration: 15000,
});
// Redirect to auth page with email pre-filled
navigate(`/auth?email=${encodeURIComponent(email)}&message=complete-password-setup`);
// Stay on settings page - user will complete setup via email link
} else if (email) {
// Fallback: direct password set (shouldn't happen with new flow)
toast({
title: 'Password Set Successfully',
description: 'You can now sign in with your email and password.',
duration: 6000,
});
} else {
// Normal password change flow (user already had email identity)
setAddingPassword(true);
@@ -185,8 +183,8 @@ export function SecurityTab() {
const result = await triggerOrphanedPasswordConfirmation('security_settings');
if (result.success) {
sonnerToast.success("Confirmation Email Sent!", {
description: "Check your email for a confirmation link to activate your password authentication.",
sonnerToast.success("Reset Email Sent!", {
description: "Check your email for a password reset link from Supabase to activate your password authentication. You'll also receive a notification email from ThrillWiki.",
duration: 15000,
});
} else {