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:
parent
8d295fd176
commit
fa9a1c3145
@ -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
|
||||||
|
@ -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 {
|
||||||
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user