- Build complete Next.js CRM for commercial real estate - Add authentication with JWT sessions and role-based access - Add GoHighLevel API integration for contacts, conversations, opportunities - Add AI-powered Control Center with tool calling - Add Setup page with onboarding checklist (/setup) - Add sidebar navigation with Setup menu item - Fix type errors in onboarding API, GHL services, and control center tools - Add Prisma schema with SQLite for local development - Add UI components with clay morphism design system Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
28 lines
668 B
TypeScript
28 lines
668 B
TypeScript
import jwt from 'jsonwebtoken';
|
|
import { User, Session, Role } from '@/types';
|
|
|
|
const JWT_SECRET = process.env.JWT_SECRET || 'dev-secret-change-in-production';
|
|
const JWT_EXPIRES_IN = '7d';
|
|
|
|
export interface JWTPayload {
|
|
userId: string;
|
|
email: string;
|
|
role: Role;
|
|
}
|
|
|
|
export function signToken(payload: JWTPayload): string {
|
|
return jwt.sign(payload, JWT_SECRET, { expiresIn: JWT_EXPIRES_IN });
|
|
}
|
|
|
|
export function verifyToken(token: string): JWTPayload {
|
|
return jwt.verify(token, JWT_SECRET) as JWTPayload;
|
|
}
|
|
|
|
export function decodeToken(token: string): JWTPayload | null {
|
|
try {
|
|
return jwt.decode(token) as JWTPayload;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|