-
Notifications
You must be signed in to change notification settings - Fork 3
[feat] account creation using only email (no phone) #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
81894da to
66e733f
Compare
brh28
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already the following definition in the graphql schema, which appears to the same or similar to what's being done in this PR:
userEmailRegistrationInitiate(input: UserEmailRegistrationInitiateInput!): UserEmailRegistrationInitiatePayload!
userEmailRegistrationValidate(input: UserEmailRegistrationValidateInput!): UserEmailRegistrationValidatePayload!
These definitions do not allow for a email registration without an existing account. The choice was to modify these, to handle both cases (with account and without account) or create a new schema definition for new accounts. |
- New GraphQL mutations: newUserEmailRegistrationInitiate and newUserEmailRegistrationValidate for email-only account creation - Kratos integration: Successfully using email recovery flow for OTP delivery - Account creation: Fixed critical bug where accounts weren't being created after validation - Code cleanup: Removed all debug console.log statements ✅ Key Changes Made 1. Fixed validation logic - Changed from checking User existence to Account existence 2. Proper account creation - Creates account with wallets when none exists 3. Clean production code - Removed debug statements for production readiness
66e733f to
90f293e
Compare
|
@brh28 please review |
| // so that if one fails, the other is rolled back | ||
|
|
||
| // 1. Update user record with email (deviceId is preserved via spread) | ||
| const userUpdated = await UsersRepository().findById(userId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 60-65 can be consolidated to a single database update. The function would be something like:
addEmail: (userId, email) => db.updateOne( { userId }, { $set: { email })
| userId: UserId | ||
| email: EmailAddress | ||
| }): Promise<Account | RepositoryError> => { | ||
| // TODO: ideally both 1. and 2. should be done in a transaction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe there's a way to make this atomic unless we completely rewrite our data model
|
|
||
| import { createAccountWithEmailIdentifier } from "@app/accounts" | ||
|
|
||
| export const createAccountFromEmailRegistrationPayload = async ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this function being called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nowhere! apparently its leftover from a previous attempt at getting this to work. Removed the file and the export reference
brh28
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do a code walk through on this one? I'm having a hard time following
|
Related to: #237 |
|
@brh28 I think this is ready for a code review again, since we patched the orphaned accounts issue. |
Email-Only Authentication Implementation
Key Changes Made