-
Notifications
You must be signed in to change notification settings - Fork 20
feat/email-registration #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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
069ba09
✅ Email-Only Authentication Implementation
islandbitcoin 50a8fff
update email pathways
islandbitcoin db02cb7
update comments
islandbitcoin 3bfe8b1
updated based on PR Feedback
islandbitcoin 204ac45
fix(types): resolve all typescript errors from main rebase
islandbitcoin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <style> | ||
| body { | ||
| font-family: Arial, sans-serif; | ||
| margin: 0; | ||
| padding: 0; | ||
| background-color: #f4f4f4; | ||
| color: #333; | ||
| } | ||
|
|
||
| .container { | ||
| max-width: 600px; | ||
| margin: 0 auto; | ||
| background-color: #ffffff; | ||
| border-radius: 8px; | ||
| overflow: hidden; | ||
| box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
| } | ||
|
|
||
| .header { | ||
| background-color: #007bff; | ||
| color: #ffffff; | ||
| text-align: center; | ||
| padding: 20px; | ||
| } | ||
|
|
||
| .header h1 { | ||
| margin: 0; | ||
| font-size: 24px; | ||
| } | ||
|
|
||
| .header img { | ||
| max-width: 100px; | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| .content { | ||
| padding: 20px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .content h2 { | ||
| font-size: 20px; | ||
| margin: 20px 0; | ||
| } | ||
|
|
||
| .content p { | ||
| font-size: 16px; | ||
| margin: 10px 0; | ||
| } | ||
|
|
||
| .code { | ||
| font-size: 24px; | ||
| font-weight: bold; | ||
| color: #007bff; | ||
| margin: 20px 0; | ||
| } | ||
|
|
||
| .footer { | ||
| background-color: #f4f4f4; | ||
| color: #777; | ||
| text-align: center; | ||
| padding: 10px; | ||
| font-size: 12px; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <div class="header"> | ||
| <h1>Welcome to Flash</h1> | ||
| <img src="https://getflash.io/assets/img/logo-white.png" alt="Welcome Image"> | ||
| </div> | ||
| <div class="content"> | ||
| <h2>Confirm Your Access</h2> | ||
| <p>Hi,</p> | ||
| <p>Confirm access to your Flash account using the following code:</p> | ||
| <div class="code">{{ .RecoveryCode }}</div> | ||
| <p>This code will only be used once. Do not share it with anyone.</p> | ||
| </div> | ||
| <div class="footer"> | ||
| <p>© 2024 Flash. All rights reserved.</p> | ||
| </div> | ||
| </div> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,42 @@ export const upgradeAccountFromDeviceToPhone = async ({ | |
|
|
||
| return accountUpdated | ||
| } | ||
|
|
||
| /** | ||
| * Upgrades a TRIAL device account to an email-based account | ||
| * | ||
| * This function updates MongoDB records after Kratos schema has been upgraded | ||
| * from username_password_deviceid_v0 to email_no_password_v0 | ||
| * | ||
| * Changes made: | ||
| * - Adds email to User record | ||
| * - Upgrades Account level from 0 (TRIAL) to 1 (verified) | ||
| * - Preserves deviceId field in User record | ||
| * | ||
| * @param userId - Kratos user ID | ||
| * @param email - Email address to add | ||
| * @returns Updated Account or RepositoryError | ||
| */ | ||
| export const upgradeAccountFromDeviceToEmail = async ({ | ||
| userId, | ||
| email, | ||
| }: { | ||
| userId: UserId | ||
| email: EmailAddress | ||
| }): Promise<Account | RepositoryError> => { | ||
| // TODO: ideally both 1. and 2. should be done in a transaction, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| // so that if one fails, the other is rolled back | ||
|
|
||
| // 1. Update user record with email (deviceId is preserved via spread) | ||
| const res = await UsersRepository().addEmail(userId, email) | ||
| if (res instanceof Error) return res | ||
|
|
||
| // 2. Update account level from TRIAL (0) to verified (1) | ||
| const accountDevice = await AccountsRepository().findByUserId(userId) | ||
| if (accountDevice instanceof Error) return accountDevice | ||
| accountDevice.level = AccountLevel.One | ||
| const accountUpdated = await AccountsRepository().update(accountDevice) | ||
| if (accountUpdated instanceof Error) return accountUpdated | ||
|
|
||
| return accountUpdated | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.