diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 21fcc02a3ff79dff90ceec70dccccbd047b2f974..59c7005ff488a2354b957ad5f56ae1f87af4de59 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -78,7 +78,7 @@ export class GameService { const gameId = await this.gameRepository.save(updatedGame); // get all the factions that are associated with the game to deny duplicate entries - const factions = await this.factionRepository.find(gameId); + const factions = await this.factionRepository.find({ game: gameId }); const factionNames = factions.map(({ factionName }) => factionName); // add the factions to db if (gameData.factions) { diff --git a/src/task/task.controller.ts b/src/task/task.controller.ts index 23c1593699525d4848649feea787af2105bb5e95..6f272a0ce4c9d51e49ec3fbba78d666e283b0910 100644 --- a/src/task/task.controller.ts +++ b/src/task/task.controller.ts @@ -33,7 +33,7 @@ export class TaskController { // creates a new task if the user has admin role in the game // :id is the id of the game @Post('new-task/:id') - @Roles('admin') + //@Roles('admin') @UsePipes(new ValidationPipe()) async newTask(@Param('id') id: string, @Body() task: TaskDTO) { return this.taskService.newTask(task); diff --git a/src/task/task.dto.ts b/src/task/task.dto.ts index 37e4fa5cb636df0cba28d03e6ca457366bf8d4c9..aa3238f888d0ad2975d4c6bab519421ddd41635d 100644 --- a/src/task/task.dto.ts +++ b/src/task/task.dto.ts @@ -1,4 +1,11 @@ -import { IsString, Length, IsNumber, IsBoolean } from 'class-validator'; +import { + IsString, + Length, + IsNumber, + IsBoolean, + Min, + Max, +} from 'class-validator'; import { FactionEntity } from 'src/game/faction.entity'; export class TaskDTO { @@ -9,7 +16,8 @@ export class TaskDTO { @Length(0, 255) taskDescription: string; @IsNumber() - @Length(1, 3) + @Min(1) + @Max(99) taskScore: number; @IsString() @Length(3, 31)