text: import database, { firebase, githubAuthProvider as provider } from '../firebase/firebase';
  
  export const login = (uid, displayName) => ({
    type: 'LOGIN',
    uid,
    displayName
  });
  
  export const startLogin = (uname, passd) => {
    return () => {
      return firebase.auth().signInWithEmailAndPassword(uname, passd).then(function(result) {
        var token = result.credential.accessToken;
        // The signed-in user info.
        var user = result.user;
        const name = user.displayName ? user.displayName : user.email;
        database.ref(`users/${user.uid}`).once((snapshot) => {
          if(!snapshot.val()) {
            database.ref(`users/${user.uid}`).set({
              name,
              uid: user.uid,
              email: user.email,
              rooms: [],
              token
            });
          }
        });
        
        // ...
      }).catch(function(error) {
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
        // The email of the user's account used.
        var email = error.email;
        // The firebase.auth.AuthCredential type that was used.
        var credential = error.credential;
        // ...
      });
    };
  };
  
  export const logout = () => ({
    type: 'LOGOUT'
  });
  
  export const startLogout = () => {
    return () => {
      return firebase.auth().signOut();
    };
  };
  