How to use the react-native-firebase.auth function in react-native-firebase

To help you get started, we’ve selected a few react-native-firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aryaminus / RN-firechat / app / components / Friendlist.js View on Github external
listenForItems(friendsRef) {
    var user = firebase.auth().currentUser;

    friendsRef.on("value", snap => {
      // get children as an array
      var items = [];
      snap.forEach(child => {
        if (child.val().email != user.email)
          items.push({
            name: child.val().name,
            uid: child.val().uid,
            email: child.val().email
          });
      });

      this.setState({
        dataSource: this.state.dataSource.cloneWithRows(items),
        loading: false
github instamobile / react-native-starter-kit / src / screens / WelcomeScreen.js View on Github external
})
        .catch(error => {
          const { code, message } = error;
          alert(message);
          // For details of error codes, see the docs
          // The message contains the default Firebase string
          // representation of the error
        });
      return;
    }
    const fbToken = await AsyncStorage.getItem(
      "@loggedInUserID:facebookCredentialAccessToken"
    );
    if (id != null && id.length > 0 && fbToken != null && fbToken.length > 0) {
      const credential = firebase.auth.FacebookAuthProvider.credential(fbToken);
      firebase
        .auth()
        .signInWithCredential(credential)
        .then(result => {
          var user = result.user;
          var userDict = {
            id: user.uid,
            fullname: user.displayName,
            email: user.email,
            profileURL: user.photoURL
          };
          this.props.navigation.dispatch({
            type: "Login",
            user: userDict
          });
        })
        .catch(error => {
github xaphod / LaneChange / app / utils / firebase.js View on Github external
export const registerFirebaseAuthHandler = (onSignedIn) => {
  firebase.auth().onAuthStateChanged((user) => {
    if (user) {
      // signed in
      if (user.isAnonymous) {
        consolelog(`DEBUG firebase: signed in anonymously as: ${user.uid}`);
      } else {
        consolelog(`DEBUG firebase: signed in to an actual account as: ${user.uid}`);
      }
      onSignedIn(user);
    } else {
      consolelog('DEBUG firebase: no user, calling signInAnonymously()');
      signInAnonymously();
    }
  });
};
github rakannimer / react-firebase / react-native-examples / react-native-firebase-starter / App.js View on Github external
onPress={async () => {
                const data = await firebase
                  .auth()
                  .signInAnonymouslyAndRetrieveData();
                console.warn(data);
              }}
            >
github aryaminus / RN-firechat / app / components / Register.js View on Github external
async onRegisterPress() {
    this.setState({ errorMessage: null, loading: true });
    const { email, password, name } = this.state;
    console.log(email);
    console.log(name);
    console.log(password);

    firebase
      .auth()
      .createUserWithEmailAndPassword(email, password)
      .then(() => {
        this.setState({ loading: false });
      })
      .catch(error => {
        var errorCode = error.code;
        var errorMessage = error.message;
        this.setState({ errorMessage, loading: false });
      });

    await AsyncStorage.setItem("email", email);
    await AsyncStorage.setItem("name", name);
    await AsyncStorage.setItem("password", password);

    firebase.auth().onAuthStateChanged(user => {
github Bruno-Furtado / fastbuy-app / src / services / FirebaseService.js View on Github external
static async signOut() {
    return await firebase.auth().signOut();
  }
github aryaminus / RN-firechat / app / components / Boiler.js View on Github external
() => {
                  firebase.auth().onAuthStateChanged(user => {
                    if (user) {
                      firebase.auth().signOut();
                    }
                  });
                },
                function(error) {
github AOSSIE-Org / CarbonFootprint-Mobile / app / actions / firebase / Auth.js View on Github external
return new Promise((resolve, reject) => {
        firebase
            .auth()
            .signInWithEmailAndPassword(email, password)
            .then(user => {
                firebase.auth().onAuthStateChanged(function(user) {
                    if (user) {
                        user = user.toJSON();
                        getUser(user.email)
                            .then(user => resolve(user))
                            .catch(error => reject(error));
                    } else {
                        reject();
                    }
                });
            })
            .catch(error => reject(error));
    });
github instamobile / react-native-starter-kit / src / screens / WelcomeScreen.js View on Github external
async tryToLoginFirst() {
    const email = await AsyncStorage.getItem("@loggedInUserID:key");
    const password = await AsyncStorage.getItem("@loggedInUserID:password");
    const id = await AsyncStorage.getItem("@loggedInUserID:id");
    if (
      id != null &&
      id.length > 0 &&
      password != null &&
      password.length > 0
    ) {
      firebase
        .auth()
        .signInWithEmailAndPassword(email, password)
        .then(user => {
          const { navigation } = this.props;
          firebase
            .firestore()
            .collection("users")
            .doc(id)
            .get()
            .then(function(doc) {
              var dict = {
                id: id,
                email: email,
                profileURL: doc.photoURL,
                fullname: doc.displayName
              };