Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix topbar logout hang and unknown env #121

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ const useInitApp = () => {
// Use authenticated username to load user's profile
const username = useAppSelector(authUsername);
const initialized = useAppSelector(authInitialized);
const environment = useAppSelector((state) => state.layout.environment);
useLoggedInProfileUser(username);

// Placeholder code for determining environment.
useEffect(() => {
// eslint-disable-next-line no-console
console.info('Static Deploy Domain:', process.env.REACT_APP_KBASE_DOMAIN);
dispatch(setEnvironment(process.env.REACT_APP_KBASE_ENV ?? 'unknown'));
}, [dispatch]);
}, [dispatch, environment]);

return { isLoading: !initialized };
};
Expand Down
3 changes: 2 additions & 1 deletion src/features/layout/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ const useLogout = () => {
revoke(tokenId)
.unwrap()
.then(() => {
dispatch(resetStateAction());
// setAuth(null) follow the state reset to initialize the page as un-Authed
dispatch(setAuth(null));
toast('You have been signed out');
dispatch(resetStateAction());
navigate('/legacy/auth2/signedout');
})
.catch(() => {
Expand Down
7 changes: 5 additions & 2 deletions src/features/legacy/Legacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { usePageTitle } from '../layout/layoutSlice';
import { useTryAuthFromToken } from '../auth/hooks';
import { useAppDispatch } from '../../common/hooks';
import { resetStateAction } from '../../app/store';
import { setAuth } from '../auth/authSlice';
import { toast } from 'react-hot-toast';

export const LEGACY_BASE_ROUTE = '/legacy';

Expand Down Expand Up @@ -51,9 +53,10 @@ export default function Legacy() {
setReceivedToken(d.payload.token);
}
} else if (isLogoutMessage(d)) {
// eslint-disable-next-line no-console
console.info('Logged Out');
dispatch(resetStateAction());
dispatch(setAuth(null));
toast('You have been signed out');
navigate('/legacy/auth2/signedout');
}
});

Expand Down
Loading