Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/email-first-registration.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 4 additions & 2 deletions src/views/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -97,7 +99,7 @@ const Login: React.FC = () => {
const data = await response.json();

if (data.message === 'Success') {
navigate('/verifyPhoneOTP');
navigate('/verifyEmailOTP');
return;
}
setFormErrors(
Expand Down
2 changes: 1 addition & 1 deletion tests/login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ describe('Login', () => {
fireEvent.click(registerButton);
});

expect(navigate).toHaveBeenCalledWith('/verifyPhoneOTP');
expect(navigate).toHaveBeenCalledWith('/verifyEmailOTP');
});
});