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
37 lines
1,022 B
TypeScript
37 lines
1,022 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { Pool } from "pg";
|
|
import { requireAdmin } from "@/lib/auth-utils";
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
});
|
|
|
|
// DELETE /api/admin/users/[id]/sessions/[sessionId] - Revoke a specific session
|
|
export async function DELETE(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ id: string; sessionId: string }> }
|
|
) {
|
|
const { error } = await requireAdmin();
|
|
if (error) return error;
|
|
|
|
try {
|
|
const { id, sessionId } = await params;
|
|
|
|
const result = await pool.query(
|
|
'DELETE FROM "session" WHERE id = $1 AND user_id = $2',
|
|
[sessionId, id]
|
|
);
|
|
|
|
if (result.rowCount === 0) {
|
|
return NextResponse.json({ error: "Session not found" }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({ success: true });
|
|
} catch (error) {
|
|
console.error("Error revoking session:", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to revoke session" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|