Added comprehensive authentication and authorization system: Authentication System: - Better Auth integration with session management - Login/logout pages and API routes - Middleware for route protection - Auth utilities and client libraries User Management: - User list, detail, and invite pages - User API endpoints (CRUD operations) - Session management for users - Profile settings page Role-Based Access Control: - Role management pages (list, create, edit) - Permission system with granular controls - Role assignment to users - Role API endpoints Admin Features: - Audit log page for tracking system events - Admin settings page - Audit service for logging user actions Additional Features: - Quotes management pages and components - SalesBldr API integration - Email service for notifications Configuration & Documentation: - Updated docker-compose.yml - MCP server configuration (mcp.json) - CVE-2025-55182 security review documentation - Standards guide and PRD documents - Re-enabling authentication documentation Database Migrations: - 012: Auth tables (users, sessions, accounts, verifications) - 013: Role tables (roles, permissions, role_permissions, user_roles) - 014: Admin settings table UI Updates: - Updated dashboard layout - Enhanced app layout with auth integration
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import { Pool } from "pg";
|
|
import { RoleForm } from "@/components/admin/roles/role-form";
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
});
|
|
|
|
interface PageProps {
|
|
params: Promise<{ id: string }>;
|
|
}
|
|
|
|
async function getRole(id: string) {
|
|
const result = await pool.query(
|
|
`SELECT id, name, description, permissions, is_system, created_at, updated_at
|
|
FROM "role" WHERE id = $1`,
|
|
[id]
|
|
);
|
|
return result.rows[0] || null;
|
|
}
|
|
|
|
export default async function EditRolePage({ params }: PageProps) {
|
|
const { id } = await params;
|
|
const role = await getRole(id);
|
|
|
|
if (!role) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<div className="container mx-auto py-8 px-4 max-w-3xl">
|
|
<Card>
|
|
<CardHeader>
|
|
<div className="flex items-center gap-2">
|
|
<CardTitle>Edit Role: {role.name}</CardTitle>
|
|
{role.is_system && <Badge variant="outline">System</Badge>}
|
|
</div>
|
|
<CardDescription>
|
|
{role.is_system
|
|
? "System roles cannot be renamed or deleted, but permissions can be modified"
|
|
: "Update role name, description, and permissions"}
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<RoleForm role={role} />
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|