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

Add support for importing users with totp second factor #2363

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

pragatimodi
Copy link
Contributor

@pragatimodi pragatimodi commented Nov 8, 2023

No integration tests.
Manually tested input

const users = [
  {
    uid: '3456',
    email: '[email protected]',
    emailVerified:true,
    multiFactor: {
      enrolledFactors: [
        {
          uid: 'enrolledSecondFactor1',
          phoneNumber: '+16505557348',
          displayName: "Spouse's phone number",
          factorId: 'phone',
          enrollmentTime: nowString,
        },
        {
          uid: 'enrolledSecondFactor2',
          phoneNumber: '+16505551000',
          factorId: 'phone',
        },
        {
          uid: 'enrolledSecondFactor3',
          enrollmentTime: nowString,
          displayName: 'displayNameTotp',
          totpInfo: {
            sharedSecretKey: 'VIAAQYSO37EKAWB2KAXEQ7EGUMLWI3P4',
          },
          factorId: 'totp',
        },
      ],
    },
  },
];

getAuth()
  .importUsers(users)
  .then((importedUsers) => {
    console.log(JSON.stringify(importedUsers));
  })
  .catch((error) => {
    console.error('Error importing users:', error);
  });

with result
{"successCount":1,"failureCount":0,"errors":[]}

Further verified with console and getUser method that user has been imported successfully.

@pragatimodi pragatimodi marked this pull request as draft November 14, 2023 19:40
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.

1 participant