✨ Features: - Complete authentication system with JWT - Dashboard with all 6 modules visible - Contact Management module (Salesforce-style) - CRM & Sales Pipeline module (Pipedrive-style) - Inventory & Assets module (SAP-style) - Tasks & Projects module (Jira/Asana-style) - HR Management module (BambooHR-style) - Marketing Management module (HubSpot-style) - Admin Panel with user management and role matrix - World-class UI/UX with RTL Arabic support - Cairo font (headings) + Readex Pro font (body) - Sample data for all modules - Protected routes and authentication flow - Backend API with Prisma + PostgreSQL - Comprehensive documentation 🎨 Design: - Color-coded modules - Professional data tables - Stats cards with metrics - Progress bars and status badges - Search and filters - Responsive layout 📊 Tech Stack: - Frontend: Next.js 14, TypeScript, Tailwind CSS - Backend: Node.js, Express, Prisma - Database: PostgreSQL - Auth: JWT with bcrypt 🚀 Production-ready frontend with all features accessible
98 lines
2.4 KiB
TypeScript
98 lines
2.4 KiB
TypeScript
import { Request, Response } from 'express'
|
|
import { authService } from './auth.service'
|
|
import { AuthRequest } from '@/shared/middleware/auth'
|
|
|
|
export const authController = {
|
|
register: async (req: Request, res: Response) => {
|
|
try {
|
|
const result = await authService.register(req.body)
|
|
res.status(201).json({
|
|
success: true,
|
|
message: 'تم التسجيل بنجاح',
|
|
data: result
|
|
})
|
|
} catch (error: any) {
|
|
res.status(400).json({
|
|
success: false,
|
|
message: error.message
|
|
})
|
|
}
|
|
},
|
|
|
|
login: async (req: Request, res: Response) => {
|
|
try {
|
|
const { email, password } = req.body
|
|
const result = await authService.login(email, password)
|
|
res.status(200).json({
|
|
success: true,
|
|
message: 'تم تسجيل الدخول بنجاح',
|
|
data: result
|
|
})
|
|
} catch (error: any) {
|
|
res.status(401).json({
|
|
success: false,
|
|
message: error.message
|
|
})
|
|
}
|
|
},
|
|
|
|
me: async (req: AuthRequest, res: Response) => {
|
|
try {
|
|
const userId = req.user?.id
|
|
if (!userId) {
|
|
return res.status(401).json({
|
|
success: false,
|
|
message: 'غير مصرح'
|
|
})
|
|
}
|
|
|
|
const user = await authService.getUserById(userId)
|
|
res.status(200).json({
|
|
success: true,
|
|
message: 'تم جلب البيانات بنجاح',
|
|
data: user
|
|
})
|
|
} catch (error: any) {
|
|
res.status(400).json({
|
|
success: false,
|
|
message: error.message
|
|
})
|
|
}
|
|
},
|
|
|
|
refreshToken: async (req: Request, res: Response) => {
|
|
try {
|
|
const { refreshToken } = req.body
|
|
const result = await authService.refreshToken(refreshToken)
|
|
res.status(200).json({
|
|
success: true,
|
|
message: 'تم تحديث الرمز بنجاح',
|
|
data: result
|
|
})
|
|
} catch (error: any) {
|
|
res.status(401).json({
|
|
success: false,
|
|
message: error.message
|
|
})
|
|
}
|
|
},
|
|
|
|
logout: async (req: AuthRequest, res: Response) => {
|
|
try {
|
|
const userId = req.user?.id
|
|
if (userId) {
|
|
await authService.logout(userId)
|
|
}
|
|
res.status(200).json({
|
|
success: true,
|
|
message: 'تم تسجيل الخروج بنجاح'
|
|
})
|
|
} catch (error: any) {
|
|
res.status(400).json({
|
|
success: false,
|
|
message: error.message
|
|
})
|
|
}
|
|
}
|
|
}
|