Private
Public Access
1
0

fix: persist auth state across page refreshes using onRehydrateStorage
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 5s
CI Pipeline / Clippy Lints (push) Successful in 49s
CI Pipeline / Rust Unit Tests (push) Successful in 1m2s
CI Pipeline / Security Audit (push) Successful in 4s
CI Pipeline / Frontend Lint & Type Check (push) Failing after 10s
CI Pipeline / Build .deb & Release (push) Has been skipped

This commit is contained in:
2026-05-07 02:59:09 +00:00
parent 5e63245f65
commit 73df591cd3
3 changed files with 51 additions and 8 deletions

View File

@ -2,6 +2,7 @@ import { Routes, Route, Navigate } from 'react-router-dom'
import { CssBaseline, ThemeProvider } from '@mui/material'
import { darkTheme } from './theme/theme'
import { useAuthStore } from './store/authStore'
import { CircularProgress, Box } from '@mui/material'
import AppLayout from './components/AppLayout'
import LoginPage from './pages/LoginPage'
import MfaSetupPage from './pages/MfaSetupPage'
@ -19,6 +20,16 @@ import SettingsPage from './pages/SettingsPage'
function RequireAuth({ children }: { children: React.ReactNode }) {
const isAuthenticated = useAuthStore((s) => s.isAuthenticated)
const isRestoring = useAuthStore((s) => s.isRestoring)
if (isRestoring) {
return (
<Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
<CircularProgress />
</Box>
)
}
return isAuthenticated ? <>{children}</> : <Navigate to="/login" replace />
}