import { auth } from '../../../services/api';
import { LOGIN_LOGOUT } from '../constants/action-types';
import { createAction } from '../../../utilities';

export const request = createAction(LOGIN_LOGOUT);

export default function () {
    return dispatch => {
        dispatch(request());

        return auth.login();
    };
}

import { LOGIN_LOGOUT } from '../constants/action-types';
import { createAction } from '../../../utilities';
import config from '../../../config';
import history from '../../../history';

const logout = createAction(LOGIN_LOGOUT);

export default function () {
    return dispatch => {
        localStorage.removeItem(config.localStorageTokenKey);
        dispatch(logout());
        history.push('/login');
    };
}

add logout action