简体   繁体   中英

Firebase Email/Password Auth not registering users

I am using Firebase for web and I am trying to register users with email and password, I have done everything they said on the docs but it is not working for some reason.
This is my submit function:

        function submitForm(){
        var email = document.getElementById("email").value;
        var password = document.getElementById("password").value;
        console.log(email, password);
        firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
            var errorCode = error.code;
            var errorMessage = error.message;
            alert("oof not valid info brochocho");
        });
        window.location = 'index.html';
        alert("registered");
    };

First verify in the Firebase console if you have enabled the login method with email and password, it is possible that you have not enabled it and therefore no user will register you. We also recommend that you show error.message in an Alert to see what exactly indicates if it is possible to attach it to support you better.

Here I leave the link for the documentation: https://firebase.google.com/docs/auth/android/password-auth

Enable access with email and password:

  1. In the Firebase console, open the Auth section.
  2. On the Access Method tab, enable the Email / password access method and click Save.
`window.location = 'index.html';

You are redirecting to another page before the sign up finished. You should have put this line in the then block of the promise returned by createUserWithEmailAndPassword .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM