diff --git a/src/actions/auth.js b/src/actions/auth.js index 477be7c9..a0e3ee84 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -6,6 +6,7 @@ const { notifSend } = notifActions; export const AUTH_REQUEST = 'AUTH_REQUEST'; export const AUTH_SUCCESS = 'AUTH_SUCCESS'; export const AUTH_FAILURE = 'AUTH_FAILURE'; +export const AUTH_REQUEST_DONE = 'AUTH_REQUEST_DONE'; export const LOGOUT = 'LOGOUT'; export function authenticating() { @@ -29,6 +30,12 @@ export function authError(error) { }; } +export function doneAuthenticating() { + return { + type: AUTH_REQUEST_DONE, + }; +} + export function logout() { return { type: LOGOUT, @@ -46,7 +53,7 @@ export function authenticateUser() { if (user) { dispatch(authenticate(user)); } else { - dispatch(logoutUser()); + dispatch(doneAuthenticating()); } }) .catch((error) => { diff --git a/src/reducers/auth.js b/src/reducers/auth.js index 93a62cb3..22bed4a7 100644 --- a/src/reducers/auth.js +++ b/src/reducers/auth.js @@ -1,5 +1,5 @@ import Immutable from 'immutable'; -import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE, LOGOUT } from '../actions/auth'; +import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE, AUTH_REQUEST_DONE, LOGOUT } from '../actions/auth'; const auth = (state = null, action) => { switch (action.type) { @@ -9,6 +9,8 @@ const auth = (state = null, action) => { return Immutable.fromJS({ user: action.payload }); case AUTH_FAILURE: return Immutable.Map({ error: action.payload.toString() }); + case AUTH_REQUEST_DONE: + return state.remove('isFetching'); case LOGOUT: return state.remove('user').remove('isFetching'); default: