mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 18:45:56 +08:00
chore: Private Wrapper is updated (#1029)
* chore: Private Wrapper is updated
This commit is contained in:
parent
5bcf42d398
commit
c969b5f329
@ -65,6 +65,8 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async (): Promise<void> => {
|
(async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
|
const isLocalStorageLoggedIn =
|
||||||
|
getLocalStorageApi(LOCALSTORAGE.IS_LOGGED_IN) === 'true';
|
||||||
if (currentRoute) {
|
if (currentRoute) {
|
||||||
const { isPrivate, key } = currentRoute;
|
const { isPrivate, key } = currentRoute;
|
||||||
|
|
||||||
@ -98,19 +100,15 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
|
|||||||
history.push(ROUTES.UN_AUTHORIZED);
|
history.push(ROUTES.UN_AUTHORIZED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
history.push(ROUTES.SOMETHING_WENT_WRONG);
|
||||||
|
|
||||||
notification.error({
|
notification.error({
|
||||||
message: response.error || t('something_went_wrong'),
|
message: response.error || t('something_went_wrong'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// user does have localstorage values
|
// user does have localstorage values
|
||||||
dispatch({
|
navigateToLoginIfNotLoggedIn(isLocalStorageLoggedIn);
|
||||||
type: UPDATE_USER_IS_FETCH,
|
|
||||||
payload: {
|
|
||||||
isUserFetching: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
history.push(ROUTES.LOGIN);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
navigateToLoginIfNotLoggedIn();
|
navigateToLoginIfNotLoggedIn();
|
||||||
@ -133,9 +131,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not found
|
// not found
|
||||||
navigateToLoginIfNotLoggedIn(
|
navigateToLoginIfNotLoggedIn(isLocalStorageLoggedIn);
|
||||||
getLocalStorageApi(LOCALSTORAGE.IS_LOGGED_IN) === 'true',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// something went wrong
|
// something went wrong
|
||||||
|
Loading…
x
Reference in New Issue
Block a user