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(node-ui): expired client key #939

Merged
merged 2 commits into from
Nov 5, 2024
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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node-ui/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
})(window.location);
</script>
<!-- End Single Page Apps for GitHub Pages -->
<script type="module" crossorigin src="/admin-dashboard/assets/main-CEAaf8Ev.js"></script>
<script type="module" crossorigin src="/admin-dashboard/assets/main-Bzv535nm.js"></script>
<link rel="stylesheet" crossorigin href="/admin-dashboard/assets/main-BesWMiQO.css">
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions node-ui/src/api/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export class AxiosHttpClient implements HttpClient {
this.axios.interceptors.response.use(
(response: AxiosResponse) => response,
(error: AxiosError) => {
if (error.response?.status === 401) {
window.location.href = '/admin-dashboard/';
}
if (!error.response) {
this.showServerDownPopup();
}
Expand Down
8 changes: 6 additions & 2 deletions node-ui/src/pages/setup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { setAppEndpointKey } from '../../utils/storage';
import { clearStorage, setAppEndpointKey } from '../../utils/storage';
import ContentWrapper from '../../components/login/ContentWrapper';
import { SetupModal } from '../../components/setup/SetupModal';
import { getNodeUrl } from '../../utils/node';

export default function SetupPage() {
const navigate = useNavigate();

useEffect(() => {
clearStorage();
}, []);

return (
<ContentWrapper>
<SetupModal
Expand Down
6 changes: 6 additions & 0 deletions node-ui/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export interface ClientKey {
publicKey: string;
}

export const clearStorage = () => {
localStorage.removeItem(APP_URL);
localStorage.removeItem(AUTHORIZED);
localStorage.removeItem(CLIENT_KEY);
};

export const getAppEndpointKey = (): string | null => {
try {
if (typeof window !== 'undefined' && window.localStorage) {
Expand Down
Loading