Skip to content
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

feat(phone): Add unconfirmed to RecoveryPhoneManager #18012

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

vbudhram
Copy link
Contributor

Because

  • We want to store the unconfirmed code in Redis

This pull request

  • Updates the RecoveryPhoneManager to store this code

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-10346

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Other information (Optional)

I took a look at adding the OtpManager (same one we use for password reset code), but we would need to refactor it a good bit to accept additional data needed for sms. To unblock other stuff, we can add that in a follow up.

@@ -11,6 +11,12 @@ describe('RecoveryPhoneManager', () => {
let recoveryPhoneManager: RecoveryPhoneManager;
let db: AccountDatabase;

const redisMock = {
Copy link
Contributor

@dschom dschom Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super small nit, we've been prefix with mock, so mockRedis would be consistent perhaps.

* @param code The SMS code associated with this user
* @returns The stored phone number data if found, or null if not found
*/
async getUnconfirmed(uid: string, code: string): Promise<any> {
Copy link
Contributor

@dschom dschom Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be Promise<{phoneNumber:string, isSetup:boolean, lookupData:Record<string, any>|null}> so it's symmetric?

lookupData: lookupData ? JSON.stringify(lookupData) : null,
};

await this.redisClient.set(redisKey, JSON.stringify(data), 'EX', 600);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should 600 be hard coded?


@Injectable()
export class RecoveryPhoneManager {
private readonly redisPrefix = 'sms-attempt';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hard coded? Maybe we need to pass in a config?

Copy link
Contributor

@dschom dschom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a couple nits take them or leave them.

@vbudhram vbudhram merged commit a2a8c19 into main Nov 14, 2024
25 checks passed
@vbudhram vbudhram deleted the fxa-10346 branch November 14, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants