Last active
October 13, 2020 18:08
-
-
Save deltaepsilon/00f9b1076689a2a5c27d4616a93495ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Authenticate with the first user then save the currentUser to a local variable | |
| var previousUser = firebase.auth().currentUser; | |
| // Authenticate with a second method and get a credential | |
| // This example shows an email/password credential, but you can get credentials from any auth provider | |
| // Note that using an OAuth provider as your se | |
| var credential = firebase.auth.EmailPasswordAuthProvider.credential(email, password); | |
| previousUser.link(credential) | |
| .catch(function (error) { | |
| // Linking will often fail if the account has already been linked. Handle these cases manually. | |
| }); | |
| // OAuth providers authenticate in an asynchronous manner, so you’ll want to perform the link account link in the callback. | |
| var previousUser = firebase.auth().currentUser; | |
| firebase.auth().signInWithPopup(new firebase.auth.GoogleAuthProvider()) | |
| .then(function (result) { | |
| return previousUser.link(result.credential); | |
| }) | |
| .catch(function (err) { | |
| // Handle error | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is a period (.) missing on line no. 15
firebase.auth().signInWithPopup(new
firebase.authGoogleAuthProvider())firebase.auth().signInWithPopup(new firebase.auth.GoogleAuthProvider())