Refactor: Implement email confirmation for password auth

This commit is contained in:
gpt-engineer-app[bot]
2025-10-14 15:39:05 +00:00
parent 92a0bf1257
commit 677f14ee7b
6 changed files with 49 additions and 26 deletions

View File

@@ -122,14 +122,22 @@ export function SecurityTab() {
}
};
const handlePasswordSetupSuccess = async (email?: string) => {
const handlePasswordSetupSuccess = (email?: string, needsConfirmation?: boolean) => {
if (email) {
// Password was set, user was logged out, needs to sign in with email/password
toast({
title: 'Password Set Successfully',
description: 'Please sign in with your email and password to complete setup.',
duration: 6000,
});
// 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,
});
}
// Redirect to auth page with email pre-filled
navigate(`/auth?email=${encodeURIComponent(email)}&message=complete-password-setup`);
@@ -137,16 +145,15 @@ export function SecurityTab() {
// Normal password change flow (user already had email identity)
setAddingPassword(true);
try {
await loadIdentities();
loadIdentities().then(() => {
toast({
title: 'Password Updated',
description: 'Your password has been successfully updated.',
});
setPasswordSetupProvider(null);
} finally {
}).finally(() => {
setAddingPassword(false);
}
});
}
};
@@ -185,7 +192,7 @@ export function SecurityTab() {
<PasswordSetupDialog
open={!!passwordSetupProvider}
onOpenChange={(open) => !open && setPasswordSetupProvider(null)}
onSuccess={handlePasswordSetupSuccess}
onSuccess={(email, needsConfirmation) => handlePasswordSetupSuccess(email, needsConfirmation)}
provider={passwordSetupProvider}
mode={addPasswordMode}
/>