1.0.3 • Published 4 years ago

x-cite-firebase-sdk v1.0.3

Weekly downloads
17
License
-
Repository
-
Last release
4 years ago

Installation

$ npm install x-cite-firebase-sdk
$ yarn add x-cite-firebase-sdk

then import the package into the used component

import Firebase from 'x-cite-firebase-sdk'

Configuration

  doCreateUserWithEmailAndPassword(email, password) {
    this.auth.createUserWithEmailAndPassword(email, password);
  }


  doSignInWithEmailAndPassword(email, password) { this.auth.signInWithEmailAndPassword(email, password); }


  doSignInWithGoogle() { this.auth.signInWithPopup(this.googleProvider); }


  doSignInWithFacebook() { this.auth.signInWithPopup(this.facebookProvider); }


  doSignInWithTwitter() { this.auth.signInWithPopup(this.twitterProvider); }


  doSignOut() { this.auth.signOut(); }


  doPasswordReset (email) {
    this.auth.sendPasswordResetEmail(email);}

  doSendEmailVerification() {
    this.auth.currentUser.sendEmailVerification({
      url: process.env.REACT_APP_CONFIRMATION_EMAIL_REDIRECT,
    });
  }


  doPasswordUpdate(password) {
    this.auth.currentUser.updatePassword(password);

    // *** Merge Auth and DB User API *** //

    onAuthUserListener(next, fallback)
    this.auth.onAuthStateChanged(authUser => {
      if (authUser) {
        this.user(authUser.uid)
          .once('value')
          .then(snapshot => {
            const dbUser = snapshot.val();

            // default empty roles
            if (!dbUser.roles) {
              dbUser.roles = {};
            }

            // merge auth and db user
            authUser = {
              uid: authUser,
              email: authUser.email,
              emailVerified: authUser.emailVerified,
              providerData: authUser.providerData,
              ...dbUser,
            };

            next(authUser);
          });
      } else {
        fallback();
      }
    });
  }

  ```User API 

  user(uid) {
    this.db.ref(`users/${uid}`);
  }

  users() {
    this.db.ref('users');
  }
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago