init = (dispatch, firebase) => {
  // exit if auth does not exist
  if (!firebase.auth) {
    return
  }
  dispatch({ type: actionTypes.AUTHENTICATION_INIT_STARTED })
  // Set Auth State listener
  firebase
    .auth()
    .onAuthStateChanged((authData) =>
      handleAuthStateChange(dispatch, firebase, authData)
    )

  // set redirect result callback if enableRedirectHandling set to true
  if (
    firebase._.config.enableRedirectHandling &&
    typeof firebase.auth().getRedirectResult === 'function' &&
    typeof window !== 'undefined' &&
    window.location &&
    window.location.protocol &&
    window.location.protocol.indexOf('http') !== -1
  ) {
    firebase
      .auth()
      .getRedirectResult()
      .then((authData) => handleRedirectResult(dispatch, firebase, authData))
      .catch((error) => {
        dispatchLoginError(dispatch, error)
        return Promise.reject(error)
      })
  }

  firebase.auth().currentUser // eslint-disable-line no-unused-expressions

  dispatch({ type: actionTypes.AUTHENTICATION_INIT_FINISHED })
}
Initialize authentication state change listener that
watches user profile and dispatches login action
@param {Function} dispatch - Action dispatch function
@param {object} firebase - Internal firebase object
@private