forked from jappel/leistungsbilanz-ts
Add login-required user management (admin/user roles, Config->Benutzer)
No self-signup: admins create every account in Config -> Benutzer with a typed start password; a forced password change gates first use. Session- cookie auth protects all /api/* routes; /api/users additionally requires the admin role. See docs/authentication.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b50c00c0ac
commit
c56cfb30ad
36 changed files with 4928 additions and 38 deletions
|
|
@ -6,6 +6,7 @@ import { useEffect, useState } from "react";
|
|||
import { listProjects } from "../utils/api";
|
||||
import type { ProjectDto } from "../types";
|
||||
import { ThemeToggle } from "./ThemeToggle";
|
||||
import { useAuth } from "./AuthProvider";
|
||||
|
||||
// Anchors on the project overview page (/projects/[id]).
|
||||
const PROJECT_SECTIONS = [
|
||||
|
|
@ -30,6 +31,7 @@ interface SidebarProps {
|
|||
|
||||
export function Sidebar({ isCollapsed, onToggleCollapsed }: SidebarProps) {
|
||||
const pathname = usePathname();
|
||||
const { user, isAdmin, logout } = useAuth();
|
||||
const projectMatch = pathname?.match(PROJECT_PATH_PATTERN);
|
||||
const activeProjectId = projectMatch ? projectMatch[1] : null;
|
||||
const projectSubPath = projectMatch?.[2] ?? "";
|
||||
|
|
@ -179,8 +181,31 @@ export function Sidebar({ isCollapsed, onToggleCollapsed }: SidebarProps) {
|
|||
</>
|
||||
)}
|
||||
</nav>
|
||||
{isAdmin && (
|
||||
<nav className="sidebar-nav sidebar-nav-bottom">
|
||||
<Link
|
||||
href="/config"
|
||||
className={pathname?.startsWith("/config") ? "sidebar-link active" : "sidebar-link"}
|
||||
title="Config"
|
||||
>
|
||||
<span className="sidebar-icon">⚙</span>
|
||||
<span className="sidebar-label">Config</span>
|
||||
</Link>
|
||||
</nav>
|
||||
)}
|
||||
<div className="sidebar-footer">
|
||||
{user && !isCollapsed && (
|
||||
<div className="sidebar-identity" title={`Angemeldet als ${user.name}`}>
|
||||
<span className="sidebar-identity-label">Angemeldet als</span>
|
||||
<span className="sidebar-identity-name">{user.name}</span>
|
||||
</div>
|
||||
)}
|
||||
<ThemeToggle />
|
||||
{user && (
|
||||
<button type="button" className="sidebar-logout" onClick={() => void logout()}>
|
||||
{isCollapsed ? "⏻" : "Abmelden"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue