@@ -443,35 +443,31 @@ export const login = (dispatch, firebase, credentials) => {
443443
444444 const { method, params } = getLoginMethodAndParams ( firebase , credentials )
445445
446- const firebaseAuth = firebase . auth ( )
447-
448- let firebaseMethod = firebaseAuth [ method ]
449-
450- // support older versions of firebase that still use signInWithCustomToken & signInWithEmailAndPassword
451- switch ( method ) {
452- case 'signInAndRetrieveDataWithCustomToken' :
453- firebaseMethod = firebaseAuth . signInWithCustomToken
454- break
455- case 'signInAndRetrieveDataWithEmailAndPassword' :
456- firebaseMethod = firebaseAuth . signInWithEmailAndPassword
457- break
458- default :
459- break
460- }
461-
462- return firebaseMethod ( ...params )
446+ return firebase
447+ . auth ( )
448+ [ method ] ( ...params )
463449 . then ( userData => {
464450 // Handle null response from getRedirectResult before redirect has happened
465451 if ( ! userData ) return Promise . resolve ( null )
466452
467453 // For email auth return uid (createUser is used for creating a profile)
468- if ( method === 'signInAndRetrieveDataWithEmailAndPassword' ) {
454+ if (
455+ [
456+ 'signInWithEmailAndPassword' ,
457+ 'signInAndRetrieveDataWithEmailAndPassword'
458+ ] . includes ( method )
459+ ) {
469460 return { user : userData }
470461 }
471462 // TODO: Only call createUserProfile once, and just pass different settings
472463
473464 // For token auth, the user key doesn't exist. Instead, return the JWT.
474- if ( method === 'signInAndRetrieveDataWithCustomToken' ) {
465+ if (
466+ [
467+ 'signInWithCustomToken' ,
468+ 'signInAndRetrieveDataWithCustomToken'
469+ ] . includes ( method )
470+ ) {
475471 if ( ! firebase . _ . config . updateProfileOnLogin ) {
476472 return { user : userData }
477473 }
0 commit comments