x-cite-firebase-sdk

1.0.3 • Public • Published

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');
  }
 
 
 
 

Package Sidebar

Install

npm i x-cite-firebase-sdk

Weekly Downloads

4

Version

1.0.3

License

none

Unpacked Size

1 MB

Total Files

6

Last publish

Collaborators

  • makremzitoun