Skip to content

Commit 9f3acf4

Browse files
committed
Fixes issue #18
Adds redirect to /home on logout. Fixes issue #18
1 parent c50319d commit 9f3acf4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/store/modules/global.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import APIService from 'services/APIService';
77

88
const userApi = new UserApi(config.api.basePath);
99

10+
//------------------------------------------------------------------------------
11+
// Constants
12+
13+
const LOGOUT_ACTION = 'LOGOUT_ACTION';
1014
const USER_INFO_KEY = 'userInfo';
1115

1216
// ------------------------------------
@@ -66,7 +70,12 @@ export const toggleNotification = createAction('TOGGLE_NOTIFICATION');
6670

6771
export const loginAction = createAction('LOGIN_ACTION');
6872

69-
export const logoutAction = createAction('LOGOUT_ACTION');
73+
export const logoutAction = () => dispatch => {
74+
browserHistory.push('/home');
75+
dispatch({
76+
type: LOGOUT_ACTION
77+
});
78+
}
7079

7180
export const signupAction = createAction('SIGNUP_ACTION');
7281

@@ -84,7 +93,7 @@ export default handleActions({
8493
[loginAction]: (state) => ({
8594
...state, loggedUser: isLogged, hasError, errorText, user: (loadUserInfo() ? loadUserInfo().user : {}),
8695
}),
87-
[logoutAction]: (state) => {
96+
[LOGOUT_ACTION]: (state) => {
8897
localStorage.removeItem(USER_INFO_KEY);
8998
APIService.accessToken = '';
9099
isLogged = false;

0 commit comments

Comments
 (0)