diff --git a/frontend/src/AuthContext.jsx b/frontend/src/AuthContext.jsx index 219fbea4..23e25a35 100644 --- a/frontend/src/AuthContext.jsx +++ b/frontend/src/AuthContext.jsx @@ -1,5 +1,5 @@ import React, { useState, createContext } from "react"; -import { AUTH_TOKEN, AUTH_USER } from "./utils/constants"; +import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "./utils/constants"; export const AuthContext = createContext(null); export function ContextWrapper(props) { @@ -19,6 +19,7 @@ export function ContextWrapper(props) { unsetUser: () => { localStorage.removeItem(AUTH_USER); localStorage.removeItem(AUTH_TOKEN); + localStorage.removeItem(AUTH_TIMESTAMP); setStore({ user: null, authToken: null }); }, }); diff --git a/frontend/src/components/Modals/Password/index.jsx b/frontend/src/components/Modals/Password/index.jsx index 11da0fc2..096906e8 100644 --- a/frontend/src/components/Modals/Password/index.jsx +++ b/frontend/src/components/Modals/Password/index.jsx @@ -2,7 +2,11 @@ import React, { useState, useEffect } from "react"; import System from "../../../models/system"; import SingleUserAuth from "./SingleUserAuth"; import MultiUserAuth from "./MultiUserAuth"; -import { AUTH_TOKEN, AUTH_USER } from "../../../utils/constants"; +import { + AUTH_TIMESTAMP, + AUTH_TOKEN, + AUTH_USER, +} from "../../../utils/constants"; export default function PasswordModal({ mode = "single" }) { return ( @@ -50,6 +54,7 @@ export function usePasswordModal() { }); window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); + window.localStorage.removeItem(AUTH_TIMESTAMP); return; } else { setAuth({ diff --git a/frontend/src/components/Modals/Settings/MultiUserMode/index.jsx b/frontend/src/components/Modals/Settings/MultiUserMode/index.jsx index 4f93d975..c54879fe 100644 --- a/frontend/src/components/Modals/Settings/MultiUserMode/index.jsx +++ b/frontend/src/components/Modals/Settings/MultiUserMode/index.jsx @@ -1,6 +1,10 @@ import React, { useState } from "react"; import System from "../../../../models/system"; -import { AUTH_TOKEN, AUTH_USER } from "../../../../utils/constants"; +import { + AUTH_TIMESTAMP, + AUTH_TOKEN, + AUTH_USER, +} from "../../../../utils/constants"; import paths from "../../../../utils/paths"; const noop = () => false; @@ -29,6 +33,7 @@ export default function MultiUserMode({ hideModal = noop }) { setTimeout(() => { window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); + window.localStorage.removeItem(AUTH_TIMESTAMP); window.location = paths.admin.users(); }, 2_000); return; diff --git a/frontend/src/components/Modals/Settings/PasswordProtection/index.jsx b/frontend/src/components/Modals/Settings/PasswordProtection/index.jsx index 3b1a92dc..a9de2cd6 100644 --- a/frontend/src/components/Modals/Settings/PasswordProtection/index.jsx +++ b/frontend/src/components/Modals/Settings/PasswordProtection/index.jsx @@ -1,6 +1,10 @@ import React, { useState } from "react"; import System from "../../../../models/system"; -import { AUTH_TOKEN, AUTH_USER } from "../../../../utils/constants"; +import { + AUTH_TIMESTAMP, + AUTH_TOKEN, + AUTH_USER, +} from "../../../../utils/constants"; import showToast from "../../../../utils/toast"; const noop = () => false; @@ -28,6 +32,7 @@ export default function PasswordProtection({ setTimeout(() => { window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); + window.localStorage.removeItem(AUTH_TIMESTAMP); window.location.reload(); }, 3_000); return; diff --git a/frontend/src/components/PrivateRoute/index.jsx b/frontend/src/components/PrivateRoute/index.jsx index 33f5c633..0829dfd5 100644 --- a/frontend/src/components/PrivateRoute/index.jsx +++ b/frontend/src/components/PrivateRoute/index.jsx @@ -3,7 +3,7 @@ import { Navigate } from "react-router-dom"; import { FullScreenLoader } from "../Preloader"; import validateSessionTokenForUser from "../../utils/session"; import paths from "../../utils/paths"; -import { AUTH_TOKEN, AUTH_USER } from "../../utils/constants"; +import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "../../utils/constants"; import { userFromStorage } from "../../utils/request"; import System from "../../models/system"; @@ -31,6 +31,7 @@ function useIsAuthenticated() { if (!isValid) { localStorage.removeItem(AUTH_USER); localStorage.removeItem(AUTH_TOKEN); + localStorage.removeItem(AUTH_TIMESTAMP); setIsAuthed(false); return; } diff --git a/frontend/src/components/Sidebar/index.jsx b/frontend/src/components/Sidebar/index.jsx index 31120812..438df1ad 100644 --- a/frontend/src/components/Sidebar/index.jsx +++ b/frontend/src/components/Sidebar/index.jsx @@ -21,7 +21,7 @@ import paths from "../../utils/paths"; import Discord from "../Icons/Discord"; import useUser from "../../hooks/useUser"; import { userFromStorage } from "../../utils/request"; -import { AUTH_TOKEN, AUTH_USER } from "../../utils/constants"; +import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "../../utils/constants"; import useLogo from "../../hooks/useLogo"; import SettingsOverlay, { useSystemSettingsOverlay } from "./SettingsOverlay"; @@ -320,6 +320,7 @@ function LogoutButton() { onClick={() => { window.localStorage.removeItem(AUTH_USER); window.localStorage.removeItem(AUTH_TOKEN); + window.localStorage.removeItem(AUTH_TIMESTAMP); window.location.replace(paths.home()); }} className="flex flex-grow w-[100%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 dark:border-transparent rounded-lg text-slate-800 dark:text-slate-200 justify-center items-center hover:bg-slate-100 dark:bg-stone-800 dark:hover:bg-stone-900"