first commit
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled

This commit is contained in:
2026-07-23 02:38:05 +03:00
commit 8757bec8ac
335 changed files with 61527 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import type { ReactNode } from 'react'
import { Navigate } from 'react-router-dom'
import { useAuth } from '@/auth/useAuth'
/**
* Route-guard админки: доступ только у пользователей с ролью
* `admin`. Оборачивается ВНУТРИ `RequireAuth` (сессия уже гарантированно
* восстановлена и `user` заполнен) — без сессии сюда не попасть.
*/
export function RequireAdmin({ children }: { children: ReactNode }) {
const { user } = useAuth()
if (user?.role !== 'admin') {
return <Navigate to="/lobby" replace />
}
return <>{children}</>
}