diff --git a/src/jobs/jobs.controller.ts b/src/jobs/jobs.controller.ts index 5cdb12ad3..5197c14ee 100644 --- a/src/jobs/jobs.controller.ts +++ b/src/jobs/jobs.controller.ts @@ -472,7 +472,6 @@ export class JobsController { ); } // verify that the user meet the requested permissions on the datasets listed - // const datasetIds = await this.checkDatasetIds(jobCreateDto.jobParams); // build the condition interface datasetsWhere { where: { @@ -679,20 +678,17 @@ export class JobsController { } const currentJobInstance = await this.generateJobInstanceForPermissions(currentJob); - currentJobInstance.configVersion = this.getJobTypeConfiguration( - currentJobInstance.type, - )[JobsConfigSchema.ConfigVersion]; const ability = this.caslAbilityFactory.createForUser( request.user as JWTUser, ); - // check if he/she can create this dataset + // check if the user can update this job const canUpdateStatus = ability.can(AuthOp.JobStatusUpdateAny, JobClass) || ability.can(AuthOp.JobStatusUpdateOwner, currentJobInstance) || ability.can(AuthOp.JobStatusUpdateConfiguration, currentJobInstance); if (!canUpdateStatus) { - throw new ForbiddenException("Unauthorized to update this dataset"); + throw new ForbiddenException("Unauthorized to update this job."); } // Update job in database @@ -704,15 +700,6 @@ export class JobsController { if (updatedJob !== null) { await this.performJobStatusUpdateAction(updatedJob); } - - // Emit update event - // MN: not needed - // if (updatedJob) { - // this.eventEmitter.emit("jobUpdated", { - // instance: updatedJob, - // hookState: { oldData: [updatedJob] }, - // }); - // } return updatedJob; } @@ -750,11 +737,11 @@ export class JobsController { const ability = this.caslAbilityFactory.createForUser( request.user as JWTUser, ); - const canCreate = + const canGet = ability.can(AuthOp.JobReadAny, JobClass) || ability.can(AuthOp.JobReadAccess, currentJobInstance); - if (!canCreate) { - throw new ForbiddenException("Unauthorized to update this dataset"); + if (!canGet) { + throw new ForbiddenException("Unauthorized to get this job."); } return currentJob; } @@ -800,25 +787,25 @@ export class JobsController { throw { message: "Invalid filter syntax." }; } // for each job run a casl JobReadOwner on a jobInstance - const datasetsFound = await this.jobsService.findAll(parsedFilter); - const datasetsAccessible: JobClass[] = []; + const jobsFound = await this.jobsService.findAll(parsedFilter); + const jobsAccessible: JobClass[] = []; const ability = this.caslAbilityFactory.createForUser( request.user as JWTUser, ); - for (const i in datasetsFound) { - // check if he/she can create this dataset + for (const i in jobsFound) { + // check if the user can get this job const jobInstance = await this.generateJobInstanceForPermissions( - datasetsFound[i], + jobsFound[i], ); const canCreate = ability.can(AuthOp.JobReadAny, JobClass) || ability.can(AuthOp.JobReadAccess, jobInstance); if (canCreate) { - datasetsAccessible.push(datasetsFound[i]); + jobsAccessible.push(jobsFound[i]); } } - return datasetsAccessible; + return jobsAccessible; } catch (e) { throw new HttpException( {