diff --git a/src/components/auth/PasswordSetupDialog.tsx b/src/components/auth/PasswordSetupDialog.tsx deleted file mode 100644 index c4e36a27..00000000 --- a/src/components/auth/PasswordSetupDialog.tsx +++ /dev/null @@ -1,176 +0,0 @@ -import { useState } from 'react'; -import { Button } from '@/components/ui/button'; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from '@/components/ui/dialog'; -import { Input } from '@/components/ui/input'; -import { Label } from '@/components/ui/label'; -import { Alert, AlertDescription } from '@/components/ui/alert'; -import { AlertCircle, CheckCircle2, Key } from 'lucide-react'; -import { addPasswordToAccount } from '@/lib/identityService'; -import type { OAuthProvider } from '@/types/identity'; - -interface PasswordSetupDialogProps { - open: boolean; - onOpenChange: (open: boolean) => void; - onSuccess: (email?: string, needsConfirmation?: boolean) => void; - provider?: OAuthProvider; - mode?: 'standalone' | 'disconnect'; -} - -export function PasswordSetupDialog({ - open, - onOpenChange, - onSuccess, - provider, - mode = 'standalone' -}: PasswordSetupDialogProps) { - const [password, setPassword] = useState(''); - const [confirmPassword, setConfirmPassword] = useState(''); - const [loading, setLoading] = useState(false); - const [error, setError] = useState(null); - - const passwordsMatch = password === confirmPassword && password.length > 0; - const passwordValid = password.length >= 8; - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setError(null); - - if (!passwordValid) { - setError('Password must be at least 8 characters long'); - return; - } - - if (!passwordsMatch) { - setError('Passwords do not match'); - return; - } - - setLoading(true); - const result = await addPasswordToAccount(password); - setLoading(false); - - if (result.success) { - setPassword(''); - setConfirmPassword(''); - - if (result.needsRelogin && result.email) { - // Pass email and confirmation flag to parent for redirect handling - onSuccess(result.email, result.needsEmailConfirmation); - } else { - onSuccess(); - } - onOpenChange(false); - } else { - setError(result.error || 'Failed to set password'); - } - }; - - return ( - - - -
- - Set Up Password -
- - {mode === 'disconnect' && provider ? ( - <> - You need to set a password before disconnecting your {provider} account. - This ensures you can still access your account. - - ) : ( - <> - Add a password to your account for increased security. You'll be able to - sign in using either your password or your connected social accounts. - - )} - -
- -
-
- - setPassword(e.target.value)} - placeholder="Enter new password" - disabled={loading} - required - /> - {password.length > 0 && ( -
- {passwordValid ? ( - - ) : ( - - )} - - At least 8 characters - -
- )} -
- -
- - setConfirmPassword(e.target.value)} - placeholder="Confirm new password" - disabled={loading} - required - /> - {confirmPassword.length > 0 && ( -
- {passwordsMatch ? ( - - ) : ( - - )} - - Passwords match - -
- )} -
- - {error && ( - - - {error} - - )} - - - - - -
-
-
- ); -}