Skip to content

Commit 42e5804

Browse files
authored
Merge pull request #153 from FoxComm/fix/dont-stay-under-profile
Redirect from profile page after logout
2 parents 3594a1b + 3d1b142 commit 42e5804

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/core/modules/auth.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createAsyncActions } from '@foxcomm/wings';
55
import { dissoc, merge, update } from 'sprout-data';
66
import { api } from 'lib/api';
77
import { setUserId } from 'lib/analytics';
8+
import { replace } from 'react-router-redux';
89

910
import type { asyncAction } from 'types';
1011

@@ -61,10 +62,15 @@ export function googleSignin(): asyncAction<void> {
6162
}
6263

6364
export const logout = createAsyncActions('auth-logout', function logout(): Promise {
65+
const { getState, dispatch } = this;
6466
return api.auth.logout()
6567
.then(() => {
68+
const { routing } = getState();
6669
api.removeAuth();
6770
this.dispatch(logoutAction());
71+
if (routing && routing.location.pathname.startsWith('/profile')) {
72+
dispatch(replace('/'));
73+
}
6874
});
6975
}).perform;
7076

0 commit comments

Comments
 (0)