1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

fix: logout redirect logic

This commit is contained in:
Fredrik Oseberg 2021-04-12 16:25:38 +02:00
parent 8d295fd176
commit fa9a1c3145
3 changed files with 5 additions and 3 deletions

View File

@ -27,9 +27,9 @@ const App = ({ location, user }: IAppProps) => {
const isUnauthorized = () => { const isUnauthorized = () => {
// authDetails only exists if the user is not logged in. // authDetails only exists if the user is not logged in.
return (
user?.authDetails !== undefined || Object.keys(user).length === 0 if (Object.keys(user).length === 0) return false;
); return user?.authDetails !== undefined;
}; };
// Change this to IRoute once snags with HashRouter and TS is worked out // Change this to IRoute once snags with HashRouter and TS is worked out

View File

@ -17,6 +17,7 @@ const Login = ({ history, loadInitialData, isUnauthorized, authDetails }) => {
const smallScreen = useMediaQuery(theme.breakpoints.up('md')); const smallScreen = useMediaQuery(theme.breakpoints.up('md'));
useEffect(() => { useEffect(() => {
console.log(isUnauthorized());
if (isUnauthorized()) { if (isUnauthorized()) {
loadInitialData(); loadInitialData();
} else { } else {

View File

@ -57,6 +57,7 @@ export function logoutUser() {
.logoutUser() .logoutUser()
.then(() => dispatch({ type: USER_LOGOUT })) .then(() => dispatch({ type: USER_LOGOUT }))
.then(() => dispatch({ type: RESET_LOADING })) .then(() => dispatch({ type: RESET_LOADING }))
.then(() => (window.location = '/'))
.catch(handleError); .catch(handleError);
}; };
} }