refactor: filter out any multifactor besides phone #8645
+12
−15
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.
Description
Our project has a web dashboard (implementing Firebase JS SDK) and react native app (using react-native-firebase) which share a Firebase project. We are planning on supporting MFA through TOTP & SMS. This is possible with the JS SDK, TOTP is currently unsupported in react-native-firebase. To get around this, we are planning on having the react native app open an external browser window to the web dashboard and have users authenticate through this. Once authenticated in the external browser, a custom token is passed back to the app and the function
signInWithCustomToken
inreact-native-firebase
is used to authenticate the user.We ran into this error when a user account who adds a TOTP MFA method on the web dashboard then attempts to log into the react-native app will encounter that crash on iOS instead of receiving a firebase auth error with code
auth/multi-factor-auth-required
. This crash also occurs when the user attempts to authenticate throughsignInWithCustomToken
.I have not encountered this crashing in Android when testing. The comparable java function
multiFactorInfoToMap
inReactNativeFirebaseAuthModule.java
does not crash.To resolve this issue I've rewritten the
convertMultiFactorData
function inRNFBAuthModule.m
so it no longer references the.phoneNumber
property of a hint which does not have that field. Because only SMS is supported, I've opted to completely filter out anyFIRMultiFactorInfo
hints which do not match theFIRPhoneMultiFactorInfo
class. The implementation is more similar to the java implementation ofmultiFactorInfoToMap
.I've also removed the
getJSFactorId
function which seemed ineffective and was no longer referenced after this refactor.I'm aware of this PR which also resolves the issue I'm trying to solve. From what I can see though that PR may take a bit longer to resolve and dependant on Android Emulator testing. If that is the case then this MR can basically be a small bridge to resolve the crash immediately at hand before working on the larger TOTP implementation.
Related issues
#8601 (comment)
Release Summary
Checklist
Android
iOS
Other
(macOS, web)e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter🔥