Firebase Detecting if user exists

后端 未结 4 1112
天涯浪人
天涯浪人 2021-01-11 12:16

How Can I Check user exists in Firebase auth in Signup Button via react native?

This is my Login Page Code:

export de         


        
4条回答
  •  庸人自扰
    2021-01-11 12:41

    It is very simple. Add a then() and catch() to your firebase method in signUp function.

    firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
    .then(()=>{
        console.log('Signup successful.');
        this.setState({
                response: 'Account Created!'
            })
       })
    .catch((error)=> {
        console.log(error.code);
        console.log(error.message);
      });
    

    Information on different Error Codes:

    • auth/email-already-in-use

      Thrown if there already exists an account with the given email address.

    • auth/invalid-email

      Thrown if the email address is not valid.

    • auth/operation-not-allowed

      Thrown if email/password accounts are not enabled. Enable email/password accounts in the Firebase Console, under the Auth tab.

    • auth/weak-password

      Thrown if the password is not strong enough.

提交回复
热议问题