feat: add authentication, user management, and admin features
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
This commit is contained in:
parent
d8e6931b85
commit
9f912aed24
68 changed files with 7651 additions and 3 deletions
40
lib/auth-client.ts
Normal file
40
lib/auth-client.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { createAuthClient } from "better-auth/react";
|
||||
import { magicLinkClient, twoFactorClient, adminClient } from "better-auth/client/plugins";
|
||||
import { ac, adminRole, userRole, superAdminRole } from "./permissions";
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL || "",
|
||||
plugins: [
|
||||
// Magic link client
|
||||
magicLinkClient(),
|
||||
|
||||
// Two-factor authentication client
|
||||
twoFactorClient({
|
||||
onTwoFactorRedirect() {
|
||||
window.location.href = "/auth/2fa";
|
||||
},
|
||||
}),
|
||||
|
||||
// Admin client with RBAC
|
||||
adminClient({
|
||||
ac,
|
||||
roles: {
|
||||
"super-admin": superAdminRole,
|
||||
admin: adminRole,
|
||||
user: userRole,
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
// Export commonly used hooks and methods
|
||||
export const {
|
||||
signIn,
|
||||
signOut,
|
||||
useSession,
|
||||
getSession,
|
||||
} = authClient;
|
||||
|
||||
// Type exports
|
||||
export type Session = typeof authClient.$Infer.Session;
|
||||
export type User = typeof authClient.$Infer.Session.user;
|
||||
Loading…
Add table
Add a link
Reference in a new issue