lundi 15 juillet 2019

Firebase: SIgn in/up via GitHub using the same button

I want to allow users to sign in/up via GitHub using firebase by clicking on the same button.

I create a new authentication for every user in the server side. With the little piece of code, I'm able to detect if either the user is new or not:

const provider = new firebase.auth.GithubAuthProvider();
    firebase.auth().signInWithPopup(provider).then((result) => {
        if (result.additionalUserInfo.isNewUser) {
             // The user is new
        } else {
             // The user is old
        }

But, when the function signInWithPopup is called, if the user is a new user, a new authentication is automatically created for him. How can I avoid this? And if the user is already authenticate, how can the user sign in from the client side? Where is the link between the authentication done from the back end with the user that wants to sign in the front end?

Aucun commentaire:

Enregistrer un commentaire