fix: memberikan akses ke mentor untuk /project/{id_project} route
This commit is contained in:
@@ -221,10 +221,21 @@ class CertificateService {
|
||||
async getProjectCertificates(id_project, actor) {
|
||||
try {
|
||||
if (!actor?.id) {
|
||||
return error(new BadRequestError('Admin ID is required'));
|
||||
return error(new BadRequestError('User ID is required'));
|
||||
}
|
||||
|
||||
if (actor.role !== 'admin') {
|
||||
const project = await certificateRepository.findProjectById(id_project);
|
||||
if (!project) {
|
||||
return error(new NotFoundError('Project not found'));
|
||||
}
|
||||
|
||||
if (actor.role === 'mentor') {
|
||||
if (project.id_admin !== parseInt(actor.id)) {
|
||||
return error(
|
||||
new ForbiddenError('Access denied: you are not the mentor of this project'),
|
||||
);
|
||||
}
|
||||
} else if (actor.role !== 'admin') {
|
||||
return error(
|
||||
new ForbiddenError('Access denied: only admins/mentors can view project certificates'),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user