Public Access
feat(auth): tell the user when the session expired
Every 401 from Auth or Core now goes through useSessionExpired: the login page says the session expired and returns to the last page after login. App no longer removes a token that only the browser clock calls expired, so a backend 401 is the one signal. A 403 on the profile now shows an error instead.
This commit is contained in:
1 parent
03259d0515
commit
d4c0f8d8f3
19 files changed
+351
-35
No files matched your search
+3
-2
@@ -13,7 +13,6 @@ import GameDetail from './pages/GameDetail.jsx';
|
||||
import AppHeader from './components/AppHeader.jsx';
|
||||
import {Toaster} from '@/components/ui/sonner';
|
||||
import {TooltipProvider} from '@/components/ui/tooltip';
|
||||
import {getValidToken} from './utils/auth.js';
|
||||
|
||||
function App() {
|
||||
const {t} = useTranslation();
|
||||
@@ -24,7 +23,9 @@ function App() {
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
setIsAuthenticated(!!getValidToken());
|
||||
// No local expiry check here: a 401 from the backend ends the session (useSessionExpired), and a browser
|
||||
// clock that runs ahead would otherwise end it silently.
|
||||
setIsAuthenticated(!!localStorage.getItem('tbp_jwt'));
|
||||
}, [location]);
|
||||
|
||||
const handleLogout = () => {
|
||||
|
||||
Reference in new issue
Block a user