-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth, multifactor): put multiFactor and getMultiFactorResolver on…
… auth() this resolves some fidelity issues with the firebase-js-sdk API this is non-breaking, the previous style from original implementation is still valid, but it will emit a warning now. Types and docs are updated Co-authored-by: Ferenc Züllich <[email protected]>
- Loading branch information
Showing
6 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -212,7 +212,7 @@ exports.createUserWithMultiFactor = async function createUserWithMultiFactor() { | |
const email = '[email protected]'; | ||
const password = 'test123'; | ||
await createVerifiedUser(email, password); | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
const session = await multiFactorUser.getSession(); | ||
const phoneNumber = getRandomPhoneNumber(); | ||
const verificationId = await firebase | ||
|
@@ -242,7 +242,7 @@ exports.signInUserWithMultiFactor = async function signInUserWithMultiFactor( | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
const resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
const resolver = firebase.auth().getMultiFactorResolver(e); | ||
let verificationId = await firebase | ||
.auth() | ||
.verifyPhoneNumberWithMultiFactorInfo(resolver.hints[0], resolver.session); | ||
|
This file contains 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 |
---|---|---|
|
@@ -41,7 +41,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
const resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
const resolver = firebase.auth().getMultiFactorResolver(e); | ||
resolver.should.be.an.Object(); | ||
resolver.hints.should.be.an.Array(); | ||
resolver.hints.length.should.equal(1); | ||
|
@@ -93,7 +93,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
const resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
const resolver = firebase.auth().getMultiFactorResolver(e); | ||
const verificationId = await firebase | ||
.auth() | ||
.verifyPhoneNumberWithMultiFactorInfo(resolver.hints[0], resolver.session); | ||
|
@@ -137,7 +137,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
const resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
const resolver = firebase.auth().getMultiFactorResolver(e); | ||
await firebase | ||
.auth() | ||
.verifyPhoneNumberWithMultiFactorInfo(resolver.hints[0], resolver.session); | ||
|
@@ -169,7 +169,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
const resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
const resolver = firebase.auth().getMultiFactorResolver(e); | ||
const unknownFactor = { | ||
uid: 'notknown', | ||
}; | ||
|
@@ -199,7 +199,7 @@ describe('multi-factor', function () { | |
await firebase.auth().signInWithEmailAndPassword(TEST_EMAIL, TEST_PASS); | ||
|
||
try { | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
const session = await multiFactorUser.getSession(); | ||
await firebase | ||
.auth() | ||
|
@@ -223,7 +223,7 @@ describe('multi-factor', function () { | |
const phoneNumber = getRandomPhoneNumber(); | ||
|
||
should.deepEqual(firebase.auth().currentUser.multiFactor.enrolledFactors, []); | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
|
||
const session = await multiFactorUser.getSession(); | ||
|
||
|
@@ -256,7 +256,7 @@ describe('multi-factor', function () { | |
const phoneNumber = getRandomPhoneNumber(); | ||
|
||
should.deepEqual(firebase.auth().currentUser.multiFactor.enrolledFactors, []); | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
|
||
const session = await multiFactorUser.getSession(); | ||
|
||
|
@@ -285,7 +285,7 @@ describe('multi-factor', function () { | |
await signInUserWithMultiFactor(email, password, phoneNumber); | ||
|
||
const anotherNumber = getRandomPhoneNumber(); | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
|
||
const session = await multiFactorUser.getSession(); | ||
const verificationId = await firebase | ||
|
@@ -318,7 +318,7 @@ describe('multi-factor', function () { | |
await clearAllUsers(); | ||
const { email, password, phoneNumber } = await createUserWithMultiFactor(); | ||
await signInUserWithMultiFactor(email, password, phoneNumber); | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
const session = await multiFactorUser.getSession(); | ||
const verificationId = await firebase | ||
|
@@ -355,7 +355,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
resolver = firebase.auth().getMultiFactorResolver(e); | ||
} | ||
await firebase | ||
.auth() | ||
|
@@ -392,7 +392,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
resolver = firebase.auth().getMultiFactorResolver(e); | ||
} | ||
|
||
try { | ||
|
@@ -420,7 +420,7 @@ describe('multi-factor', function () { | |
e.message.should.equal( | ||
'[auth/multi-factor-auth-required] Please complete a second factor challenge to finish signing into this account.', | ||
); | ||
resolver = firebase.auth.getMultiFactorResolver(firebase.auth(), e); | ||
resolver = firebase.auth().getMultiFactorResolver(e); | ||
} | ||
const verificationId = await firebase | ||
.auth() | ||
|
@@ -461,7 +461,7 @@ describe('multi-factor', function () { | |
await confirmResult.confirm(lastSmsCode); | ||
|
||
// WHEN they attempt to enroll a second factor | ||
const multiFactorUser = await firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = await firebase.auth().multiFactor(firebase.auth().currentUser); | ||
const session = await multiFactorUser.getSession(); | ||
try { | ||
await firebase.auth().verifyPhoneNumberForMultiFactor({ phoneNumber: '+1123123', session }); | ||
|
@@ -477,7 +477,7 @@ describe('multi-factor', function () { | |
}); | ||
it('can not enroll when phone number is missing + sign', async function () { | ||
await createVerifiedUser('[email protected]', 'test123'); | ||
const multiFactorUser = firebase.auth.multiFactor(firebase.auth()); | ||
const multiFactorUser = firebase.auth().multiFactor(firebase.auth().currentUser); | ||
const session = await multiFactorUser.getSession(); | ||
try { | ||
await firebase.auth().verifyPhoneNumberForMultiFactor({ phoneNumber: '491575', session }); | ||
|
This file contains 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 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 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
357094e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-native-firebase – ./
react-native-firebase.vercel.app
react-native-firebase-invertase.vercel.app
react-native-firebase-git-main-invertase.vercel.app
rnfirebase.io