diff --git a/src/modules/auth/components/RegisterForm.jsx b/src/modules/auth/components/RegisterForm.jsx index 8f2a397..07e88b9 100644 --- a/src/modules/auth/components/RegisterForm.jsx +++ b/src/modules/auth/components/RegisterForm.jsx @@ -159,6 +159,11 @@ export function RegisterForm({ className, ...props }) { const [isResuming, setIsResuming] = useState(false) const [pendingCreds, setPendingCreds] = useState(null) + // ── Confirm-before-create (asked before the register request ever fires) ── + const [confirmCreateOpen, setConfirmCreateOpen] = useState(false) + const [isCreating, setIsCreating] = useState(false) + const [pendingCredsData, setPendingCredsData] = useState(null) + // ── Warn before the tab is closed/reloaded mid-registration ──────────────── // Once the user reaches Credentials, submitting can already create a // server-side account + send an OTP — losing the tab here (slow internet, @@ -262,7 +267,24 @@ export function RegisterForm({ className, ...props }) { setStep(2) } - const onCredentialsSubmit = (data) => submitRegistration(data) + // Validated credentials don't submit yet — stage them and ask for explicit + // confirmation first, since this is the step that actually creates the + // server-side account and sends an OTP. + const onCredentialsSubmit = (data) => { + setPendingCredsData(data) + setConfirmCreateOpen(true) + } + + const handleConfirmCreate = async () => { + if (!pendingCredsData) return + setIsCreating(true) + try { + await submitRegistration(pendingCredsData) + } finally { + setIsCreating(false) + setConfirmCreateOpen(false) + } + } const handleConfirmResume = async () => { if (!pendingCreds) return @@ -440,7 +462,7 @@ export function RegisterForm({ className, ...props }) {
@@ -581,15 +603,8 @@ export function RegisterForm({ className, ...props }) { > ← Back -