Personal Dashboard

auth.js 421B

1234567891011121314
  1. import firebase from 'firebase'
  2. import { dispatch } from 'redux'
  3. import Store, { actions } from './Store'
  4. import config from './config'
  5. firebase.initializeApp(config)
  6. firebase.auth().onAuthStateChanged(user => {
  7. if (user) {
  8. const { email, displayName, photoURL } = user
  9. Store.dispatch(actions.LOGIN({ email, displayName, photoURL }))
  10. } else if (Store.getState().user)
  11. Store.dispatch(actions.LOGOUT())
  12. })