MetaPhase-Consulting/State-TalentMAP

View on GitHub
src/lib/check-auth.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { setClient } from '../client/actions';
import { auth } from '../login/sagas';

function checkAuthentication(dispatch) {
  // attempt to grab the token from localstorage
  const token = auth.get();

  // if it exists
  if (token) {
    // update our redux state with the token and return true
    dispatch(setClient(token));
    return true;
  }

  return false;
}

export default ({ dispatch }) => checkAuthentication(dispatch);