Skip to content

Commit

Permalink
fix(node-ui): expired client key (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
frdomovic authored Nov 5, 2024
1 parent f9a0e15 commit cd3a318
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.

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

0 comments on commit cd3a318

Please sign in to comment.