Add JWT authentication with animated login page
- Backend: JWT auth with /api/auth/login and /api/auth/verify endpoints - Middleware: requireAuth protects all /api routes except /api/auth - Frontend: Animated characters login page with eye-tracking effects - Auth state persisted in localStorage with token verification on mount - Sidebar logout button, 401 auto-logout, 30-day token expiry - shadcn button, input, checkbox, label components added Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Settings,
|
||||
HelpCircle,
|
||||
Server,
|
||||
LogOut,
|
||||
} from "lucide-react"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
@@ -33,6 +34,7 @@ const bottomNav: NavItem[] = [
|
||||
interface SidebarProps {
|
||||
activePage: string
|
||||
onNavigate: (page: string) => void
|
||||
onLogout?: () => void
|
||||
}
|
||||
|
||||
function NavButton({
|
||||
@@ -61,7 +63,7 @@ function NavButton({
|
||||
)
|
||||
}
|
||||
|
||||
export function Sidebar({ activePage, onNavigate }: SidebarProps) {
|
||||
export function Sidebar({ activePage, onNavigate, onLogout }: SidebarProps) {
|
||||
return (
|
||||
<aside className="flex h-screen w-60 shrink-0 flex-col border-r bg-sidebar-background">
|
||||
{/* Brand */}
|
||||
@@ -114,6 +116,17 @@ export function Sidebar({ activePage, onNavigate }: SidebarProps) {
|
||||
All Systems Operational
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Logout */}
|
||||
{onLogout && (
|
||||
<button
|
||||
onClick={onLogout}
|
||||
className="mb-4 flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-red-50 hover:text-red-600 cursor-pointer"
|
||||
>
|
||||
<LogOut className="size-5 shrink-0" />
|
||||
<span>Sign Out</span>
|
||||
</button>
|
||||
)}
|
||||
</nav>
|
||||
</aside>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user