logout = (dispatch, firebase) => {
  // detach profile listener before logging out to prevent permission_denied
  // errors (for more info see #494)
  unWatchUserProfile(firebase)
  return firebase
    .auth()
    .signOut()
    .then(() => {
      const action = {
        type: actionTypes.LOGOUT
      }
      if (firebase._.config.preserveOnLogout) {
        action.preserve = firebase._.config.preserveOnLogout
      }
      dispatch(action)
      firebase._.authUid = null
      return firebase
    })
}
Logout of firebase and dispatch logout event
@param {Function} dispatch - Action dispatch function
@param {object} firebase - Internal firebase object
@returns {Promise} Resolves after logging out
@private