linkWithCredential = (dispatch, firebase, credential) => {
  dispatch({ type: actionTypes.AUTH_LINK_START })

  // reject and dispatch error if not logged in
  if (!firebase.auth().currentUser) {
    const error = new Error('User must be logged in to link with credential.')
    dispatch({ type: actionTypes.AUTH_LINK_ERROR, error })
    return Promise.reject(error)
  }

  return firebase
    .auth()
    .currentUser.linkWithCredential(credential)
    .then((auth) => {
      dispatch({ type: actionTypes.AUTH_LINK_SUCCESS, payload: auth })
      return auth
    })
    .catch((error) => {
      dispatch({ type: actionTypes.AUTH_LINK_ERROR, error })
      return Promise.reject(error)
    })
}
Links the user account with the given credentials. Internally
calls `firebase.auth().currentUser.linkWithCredential`.
@param {Function} dispatch - Action dispatch function
@param {object} firebase - Internal firebase object
@param {object} credential - Credential with which to link user account
@returns {Promise} Resolves with auth