diff --git a/.changeset/email-first-registration.md b/.changeset/email-first-registration.md new file mode 100644 index 0000000..9109d4d --- /dev/null +++ b/.changeset/email-first-registration.md @@ -0,0 +1,9 @@ +--- +"@seamless-auth/react": patch +--- + +Register with just an email. The registration form no longer requires a phone +number (it stays optional, validated only when provided), and a successful +registration now routes to email verification (`/verifyEmailOTP`) instead of +phone verification — matching the auth server's email-first registration. After +verifying the email code the user is signed in. diff --git a/src/views/Login.tsx b/src/views/Login.tsx index ef9d7a9..923fe54 100644 --- a/src/views/Login.tsx +++ b/src/views/Login.tsx @@ -76,7 +76,9 @@ const Login: React.FC = () => { return isValidEmail(identifier) || isValidPhoneNumber(identifier); } - return isValidEmail(email) && isValidPhoneNumber(phone); + // Registration starts with just an email; a phone is optional but, if given, + // must be valid. + return isValidEmail(email) && (!phone || isValidPhoneNumber(phone)); }; const register = async () => { @@ -97,7 +99,7 @@ const Login: React.FC = () => { const data = await response.json(); if (data.message === 'Success') { - navigate('/verifyPhoneOTP'); + navigate('/verifyEmailOTP'); return; } setFormErrors( diff --git a/tests/login.test.tsx b/tests/login.test.tsx index 26e27e6..0ebfa73 100644 --- a/tests/login.test.tsx +++ b/tests/login.test.tsx @@ -293,6 +293,6 @@ describe('Login', () => { fireEvent.click(registerButton); }); - expect(navigate).toHaveBeenCalledWith('/verifyPhoneOTP'); + expect(navigate).toHaveBeenCalledWith('/verifyEmailOTP'); }); });