feat: integrate audit logging across authentication, course management, and user operations
Add comprehensive audit trail tracking by integrating auditService throughout the application. Track user authentication (LOGIN, REGISTER), course lifecycle (CREATE, APPROVE_COURSE, REJECT_COURSE, ENROLL), content management (CREATE/DELETE Chapter/Lesson), file operations (UPLOAD_FILE, DELETE_FILE for videos and attachments), password management (CHANGE_PASSWORD, RESET_PASSWORD), user role updates (UPDATE
This commit is contained in:
parent
923c8b727a
commit
108f1b73f2
10 changed files with 701 additions and 0 deletions
|
|
@ -9,6 +9,8 @@ import {
|
|||
ApproveCourseResponse,
|
||||
RejectCourseResponse,
|
||||
} from '../types/AdminCourseApproval.types';
|
||||
import { auditService } from './audit.service';
|
||||
import { AuditAction } from '@prisma/client';
|
||||
|
||||
export class AdminCourseApprovalService {
|
||||
|
||||
|
|
@ -235,6 +237,17 @@ export class AdminCourseApprovalService {
|
|||
})
|
||||
]);
|
||||
|
||||
// Audit log - APPROVE_COURSE
|
||||
await auditService.logSync({
|
||||
userId: decoded.id,
|
||||
action: AuditAction.APPROVE_COURSE,
|
||||
entityType: 'Course',
|
||||
entityId: courseId,
|
||||
oldValue: { status: 'PENDING' },
|
||||
newValue: { status: 'APPROVED' },
|
||||
metadata: { comment: comment || null }
|
||||
});
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
message: 'Course approved successfully'
|
||||
|
|
@ -290,6 +303,17 @@ export class AdminCourseApprovalService {
|
|||
})
|
||||
]);
|
||||
|
||||
// Audit log - REJECT_COURSE
|
||||
await auditService.logSync({
|
||||
userId: decoded.id,
|
||||
action: AuditAction.REJECT_COURSE,
|
||||
entityType: 'Course',
|
||||
entityId: courseId,
|
||||
oldValue: { status: 'PENDING' },
|
||||
newValue: { status: 'DRAFT' },
|
||||
metadata: { comment: comment }
|
||||
});
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
message: 'Course rejected successfully'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue