spa-csrf-fix
Some checks failed
Deploy on push / deploy (push) Failing after 4s

This commit is contained in:
2025-07-25 09:42:43 +03:00
parent e0f6b7d2be
commit 0bccd0d87e
6 changed files with 150 additions and 248 deletions

View File

@@ -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>