This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -819,7 +819,17 @@ firebase.login = function (arg) {
819819 if ( ! arg . email || ! arg . password ) {
820820 reject ( "Auth type emailandpassword requires an email and password argument" ) ;
821821 } else {
822- firebaseAuth . signInWithEmailAndPassword ( arg . email , arg . password ) . addOnCompleteListener ( onCompleteListener ) ;
822+ var user = com . google . firebase . auth . FirebaseAuth . getInstance ( ) . getCurrentUser ( ) ;
823+ if ( user ) {
824+ if ( firebase . _alreadyLinkedToAuthProvider ( user , "password" ) ) {
825+ firebaseAuth . signInWithEmailAndPassword ( arg . email , arg . password ) . addOnCompleteListener ( onCompleteListener ) ;
826+ } else {
827+ var authCredential = com . google . firebase . auth . EmailAuthProvider . getCredential ( arg . email , arg . password ) ;
828+ user . linkWithCredential ( authCredential ) . addOnCompleteListener ( onCompleteListener ) ;
829+ }
830+ } else {
831+ firebaseAuth . signInWithEmailAndPassword ( arg . email , arg . password ) . addOnCompleteListener ( onCompleteListener ) ;
832+ }
823833 }
824834
825835 } else if ( arg . type === firebase . LoginType . CUSTOM ) {
You can’t perform that action at this time.
0 commit comments