Skip to content

BUG: UpdateUser() is not able to update MFA #529

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
brokeyourbike opened this issue Dec 13, 2022 · 1 comment
Closed

BUG: UpdateUser() is not able to update MFA #529

brokeyourbike opened this issue Dec 13, 2022 · 1 comment
Assignees

Comments

@brokeyourbike
Copy link
Contributor

brokeyourbike commented Dec 13, 2022

Describe your environment

  • Operating System version: Mac OS Ventura 13.0.1
  • Firebase SDK version: Firebase Admin SDK v4
  • Library version: v4.10.0
  • Firebase Product: auth

Describe the problem

It's not possible to update multi factor enrollments with UpdateUser() function. Create and update API requests have different structure when we speaking about MFA (don't know who thought it will be cool to do that). It's also not required to pass fields like UID or DisplayName when updating or creating MFA.

We can see the valid implementation in the firebase-admin-node repository

Steps to reproduce:

  1. Create user (or have existing firebase user) without MFA
  2. Try to add MFA with UpdateUser
  3. Nothing will happen, used will not have MFA after update

Relevant Code:

// 1. Create user
createParams := (&auth.UserToCreate{}).
		UID("01GM6YCBT7T0VNPNTCP44S7E8G").
		Email("[email protected]").
		EmailVerified(true).
		Password("secret").
		DisplayName("John Doe").
		Disabled(false).
                MFASettings(auth.MultiFactorSettings{EnrolledFactors: nil})

user, err := firebaseAuth.CreateUser(ctx, params)
require.NoError(t, err)

// 2. Update user
updateParams := (&auth.UserToUpdate{}).
		MFASettings(auth.MultiFactorSettings{
			EnrolledFactors: []*auth.MultiFactorInfo{{
                                // problems will arise even on this stage
                                // because library things that it's required to pass UID and DisplayName
				FactorID:    "phone",
				PhoneNumber: "+16505557348",
			}},
		})

user, err = firebaseAuth.UpdateUser(ctx, user.UID, params)
assert.NoError(t, err)
assert.Len(t, user.MultiFactor.EnrolledFactors, 1)
@pragatimodi
Copy link
Contributor

Since this PR has been merged, marking this issue as closed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants