Implement rate limiting and enhance authentication flow
CI / Backend (build + test) (push) Successful in 1m17s
CI / Frontend (lint + typecheck + build) (push) Successful in 35s

- Added rate limiting configuration for authentication endpoints, allowing customizable request limits via environment variables.
- Updated authentication flow to utilize HttpRequest for cookie management, ensuring secure handling of refresh tokens.
- Introduced a new endpoint to retrieve user subscription details.
- Enhanced the handling of Telegram bot token validation to prevent errors with empty tokens.
- Updated the application to serialize enums as strings for better documentation and compatibility with TypeScript.
- Improved test coverage for new features and adjustments in command handlers.
This commit is contained in:
Leonid Pershin
2026-07-02 12:40:23 +03:00
parent ed07221ca5
commit 8067be3c35
106 changed files with 8823 additions and 172 deletions
+97
View File
@@ -0,0 +1,97 @@
import { useEffect } from 'react'
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { useTheme, type Theme } from '@/theme/ThemeProvider'
import { setLanguage } from '@/shared/lib/i18n'
import { Toaster } from '@/shared/ui/toaster'
import { Button } from '@/shared/ui/button'
import { useAuthStore } from '@/features/auth/store'
import { bootstrapSession, clearSession, logout } from '@/features/auth/api'
export const Route = createRootRoute({ component: RootLayout })
function RootLayout() {
const { t, i18n } = useTranslation()
const { theme, setTheme } = useTheme()
const { user, isBootstrapping } = useAuthStore()
useEffect(() => {
void bootstrapSession()
}, [])
const themes: Theme[] = ['light', 'dark', 'system']
const langs = ['ru', 'en']
const handleLogout = async () => {
try {
await logout()
} finally {
clearSession()
}
}
return (
<div className="flex min-h-svh flex-col">
<header className="flex items-center justify-between border-b border-border px-6 py-4">
<Link to="/" className="text-lg font-semibold text-primary">
{t('appName')}
</Link>
<nav className="flex items-center gap-4 text-sm">
{!isBootstrapping && user && (
<>
<Link to="/dashboard" className="text-muted-foreground hover:text-foreground">
{t('nav.dashboard')}
</Link>
<Link to="/instructions" className="text-muted-foreground hover:text-foreground">
{t('nav.instructions')}
</Link>
<Link to="/settings" className="text-muted-foreground hover:text-foreground">
{t('nav.settings')}
</Link>
{user.role === 'admin' && (
<Link to="/admin" className="text-muted-foreground hover:text-foreground">
{t('nav.admin')}
</Link>
)}
<Button variant="ghost" size="sm" onClick={handleLogout}>
{t('nav.logout')}
</Button>
</>
)}
<label className="flex items-center gap-2">
<select
className="rounded-md border border-border bg-muted px-2 py-1"
value={i18n.language}
onChange={(e) => setLanguage(e.target.value)}
>
{langs.map((l) => (
<option key={l} value={l}>
{l.toUpperCase()}
</option>
))}
</select>
</label>
<label className="flex items-center gap-2">
<select
className="rounded-md border border-border bg-muted px-2 py-1"
value={theme}
onChange={(e) => setTheme(e.target.value as Theme)}
>
{themes.map((th) => (
<option key={th} value={th}>
{t(th)}
</option>
))}
</select>
</label>
</nav>
</header>
<main className="flex flex-1 flex-col">
<Outlet />
</main>
<Toaster />
</div>
)
}