mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
feat(web): add /machinery/logout (#177)
This commit is contained in:
parent
410e27c2b3
commit
0c586404e8
3 changed files with 30 additions and 0 deletions
|
@ -7,6 +7,7 @@ const PickerPage = React.lazy(() => import('../pages/picker'));
|
|||
|
||||
const AuthLogin = React.lazy(() => import('../pages/auth/login'));
|
||||
const MachineryNewSession = React.lazy(() => import('../pages/machinery/new-session'));
|
||||
const MachineryLogout = React.lazy(() => import('../pages/machinery/logout'));
|
||||
|
||||
const DevToolsSetApi = React.lazy(() => import('../pages/dev-tools/set-api'));
|
||||
const DevToolsSessionDebug = React.lazy(() => import('../pages/dev-tools/session-debug'));
|
||||
|
@ -29,6 +30,7 @@ export const AppRouter = () => {
|
|||
<RouteWrapper component={PickerPage} path="/s/:serverID" />
|
||||
|
||||
<RouteWrapper component={MachineryNewSession} path="/machinery/new-session" />
|
||||
<RouteWrapper component={MachineryLogout} path="/machinery/logout" />
|
||||
<RouteWrapper component={AuthLogin} path="/auth/login" />
|
||||
|
||||
<RouteWrapper component={DevToolsSetApi} path="/x/dev-tools/set-api" />
|
||||
|
|
15
packages/web/src/pages/machinery/logout.spec.tsx
Normal file
15
packages/web/src/pages/machinery/logout.spec.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { render } from '@testing-library/react';
|
||||
import Logout from './logout';
|
||||
|
||||
it('removes session state from storage', () => {
|
||||
localStorage.setItem('rp_session_key', 'sessionKey');
|
||||
sessionStorage.setItem(
|
||||
'rp_session_data',
|
||||
JSON.stringify({ user: { name: 'okano', discriminator: '0001' }, guilds: [] })
|
||||
);
|
||||
|
||||
render(<Logout />);
|
||||
|
||||
expect(localStorage.getItem('rp_session_key')).toBeNull();
|
||||
expect(sessionStorage.getItem('rp_session_data')).toBeNull();
|
||||
});
|
13
packages/web/src/pages/machinery/logout.tsx
Normal file
13
packages/web/src/pages/machinery/logout.tsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React from 'react';
|
||||
|
||||
const Logout = () => {
|
||||
React.useEffect(() => {
|
||||
localStorage.removeItem('rp_session_key');
|
||||
sessionStorage.clear();
|
||||
window.location.href = '/';
|
||||
}, []);
|
||||
|
||||
return <div>Logging you out...</div>;
|
||||
};
|
||||
|
||||
export default Logout;
|
Loading…
Add table
Reference in a new issue