This commit is contained in:
@@ -9,11 +9,23 @@ import AdminPage from '../routes/admin'
|
||||
export const ProtectedRoute = () => {
|
||||
console.log('[ProtectedRoute] Checking authentication...')
|
||||
const auth = useAuth()
|
||||
const isReady = auth.isReady()
|
||||
const authenticated = auth.isAuthenticated()
|
||||
console.log(
|
||||
`[ProtectedRoute] Authentication state: ${authenticated ? 'authenticated' : 'not authenticated'}`
|
||||
)
|
||||
|
||||
console.log(`[ProtectedRoute] Auth state: ready=${isReady}, authenticated=${authenticated}`)
|
||||
|
||||
// Если авторизация еще не готова, показываем загрузку
|
||||
if (!isReady) {
|
||||
console.log('[ProtectedRoute] Auth not ready, showing loading...')
|
||||
return (
|
||||
<div class="loading-screen">
|
||||
<div class="loading-spinner" />
|
||||
<div>Инициализация авторизации...</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Если авторизация готова, но пользователь не аутентифицирован
|
||||
if (!authenticated) {
|
||||
console.log('[ProtectedRoute] Not authenticated, redirecting to login...')
|
||||
// Используем window.location.href для редиректа
|
||||
@@ -21,11 +33,12 @@ export const ProtectedRoute = () => {
|
||||
return (
|
||||
<div class="loading-screen">
|
||||
<div class="loading-spinner" />
|
||||
<div>Проверка авторизации...</div>
|
||||
<div>Перенаправление на страницу входа...</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
console.log('[ProtectedRoute] Auth ready and authenticated, rendering admin panel...')
|
||||
return (
|
||||
<DataProvider>
|
||||
<TableSortProvider>
|
||||
|
Reference in New Issue
Block a user