feat: RBAC Phase 2a - Bienenvolk-Kern auf @RequirePermission umgestellt
Apiaries, Colonies, Queens, Inspections (+ ColonyInspections), Tasks, TaskTemplates: @Roles(...) durch @RequirePermission(...) ersetzt. Schliesst dabei die bisher ungeschuetzten GET-Routen (jeder eingeloggte Nutzer konnte lesen, unabhaengig von seiner Rolle) mit :read-Rechten. TaskTemplatesController verliert seinen klassenweiten @Roles-Blanket zugunsten pro-Route-Rechten (gleiche effektive Berechtigung: nur ADMIN/BEEKEEPER, jetzt ueber task-templates:* statt Rollen-Liste). Verifiziert: tsc, lint, e2e (apiaries/colonies/queens/inspections/ tasks/task-templates, 29/29 gruen). Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
139ea6fdd7
commit
f4b174ec56
7 files changed
+52
-38
No files matched your search
@@ -8,8 +8,8 @@ import {
|
|||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { ApiaryStatus, LegacyRole as Role } from '../../generated/prisma';
|
import { ApiaryStatus } from '../../generated/prisma';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateApiaryDto } from './dto/create-apiary.dto';
|
import { CreateApiaryDto } from './dto/create-apiary.dto';
|
||||||
@@ -22,6 +22,7 @@ import { ApiariesService } from './apiaries.service';
|
|||||||
export class ApiariesController {
|
export class ApiariesController {
|
||||||
constructor(private readonly apiariesService: ApiariesService) {}
|
constructor(private readonly apiariesService: ApiariesService) {}
|
||||||
|
|
||||||
|
@RequirePermission('apiaries:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll(
|
findAll(
|
||||||
@Query('status') status?: ApiaryStatus,
|
@Query('status') status?: ApiaryStatus,
|
||||||
@@ -30,12 +31,13 @@ export class ApiariesController {
|
|||||||
return this.apiariesService.findAll({ status, location });
|
return this.apiariesService.findAll({ status, location });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('apiaries:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.apiariesService.findById(id);
|
return this.apiariesService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('apiaries:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateApiaryDto,
|
@Body() dto: CreateApiaryDto,
|
||||||
@@ -44,7 +46,7 @@ export class ApiariesController {
|
|||||||
return this.apiariesService.create(dto, actor.id);
|
return this.apiariesService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('apiaries:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -54,13 +56,13 @@ export class ApiariesController {
|
|||||||
return this.apiariesService.update(id, dto, actor.id);
|
return this.apiariesService.update(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('apiaries:deactivate')
|
||||||
@Post(':id/deactivate')
|
@Post(':id/deactivate')
|
||||||
deactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
deactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.apiariesService.deactivate(id, actor.id);
|
return this.apiariesService.deactivate(id, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('apiaries:deactivate')
|
||||||
@Post(':id/reactivate')
|
@Post(':id/reactivate')
|
||||||
reactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
reactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.apiariesService.reactivate(id, actor.id);
|
return this.apiariesService.reactivate(id, actor.id);
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import {
|
|||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { ColonyStatus, LegacyRole as Role } from '../../generated/prisma';
|
import { ColonyStatus } from '../../generated/prisma';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateColonyDto } from './dto/create-colony.dto';
|
import { CreateColonyDto } from './dto/create-colony.dto';
|
||||||
@@ -25,6 +25,7 @@ import { ColoniesService } from './colonies.service';
|
|||||||
export class ColoniesController {
|
export class ColoniesController {
|
||||||
constructor(private readonly coloniesService: ColoniesService) {}
|
constructor(private readonly coloniesService: ColoniesService) {}
|
||||||
|
|
||||||
|
@RequirePermission('colonies:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll(
|
findAll(
|
||||||
@Query('status') status?: ColonyStatus,
|
@Query('status') status?: ColonyStatus,
|
||||||
@@ -33,17 +34,19 @@ export class ColoniesController {
|
|||||||
return this.coloniesService.findAll({ status, apiaryId });
|
return this.coloniesService.findAll({ status, apiaryId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('colonies:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.coloniesService.findById(id);
|
return this.coloniesService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('colonies:read')
|
||||||
@Get(':id/history')
|
@Get(':id/history')
|
||||||
getHistory(@Param('id') id: string) {
|
getHistory(@Param('id') id: string) {
|
||||||
return this.coloniesService.getHistory(id);
|
return this.coloniesService.getHistory(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateColonyDto,
|
@Body() dto: CreateColonyDto,
|
||||||
@@ -52,7 +55,7 @@ export class ColoniesController {
|
|||||||
return this.coloniesService.create(dto, actor.id);
|
return this.coloniesService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -62,7 +65,7 @@ export class ColoniesController {
|
|||||||
return this.coloniesService.update(id, dto, actor.id);
|
return this.coloniesService.update(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:manage-lifecycle')
|
||||||
@Post(':id/move')
|
@Post(':id/move')
|
||||||
move(
|
move(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -72,7 +75,7 @@ export class ColoniesController {
|
|||||||
return this.coloniesService.move(id, dto, actor.id);
|
return this.coloniesService.move(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:manage-lifecycle')
|
||||||
@Post(':id/split')
|
@Post(':id/split')
|
||||||
split(
|
split(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -82,7 +85,7 @@ export class ColoniesController {
|
|||||||
return this.coloniesService.split(id, dto, actor.id);
|
return this.coloniesService.split(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:manage-lifecycle')
|
||||||
@Post(':id/merge')
|
@Post(':id/merge')
|
||||||
merge(
|
merge(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -92,13 +95,13 @@ export class ColoniesController {
|
|||||||
return this.coloniesService.merge(id, dto, actor.id);
|
return this.coloniesService.merge(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:manage-lifecycle')
|
||||||
@Post(':id/dissolve')
|
@Post(':id/dissolve')
|
||||||
dissolve(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
dissolve(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.coloniesService.dissolve(id, actor.id);
|
return this.coloniesService.dissolve(id, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('colonies:deactivate')
|
||||||
@Post(':id/reactivate')
|
@Post(':id/reactivate')
|
||||||
reactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
reactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.coloniesService.reactivate(id, actor.id);
|
return this.coloniesService.reactivate(id, actor.id);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { Controller, Get, Param } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { InspectionsService } from './inspections.service';
|
import { InspectionsService } from './inspections.service';
|
||||||
|
|
||||||
@ApiTags('inspections')
|
@ApiTags('inspections')
|
||||||
@@ -8,6 +9,7 @@ import { InspectionsService } from './inspections.service';
|
|||||||
export class ColonyInspectionsController {
|
export class ColonyInspectionsController {
|
||||||
constructor(private readonly inspectionsService: InspectionsService) {}
|
constructor(private readonly inspectionsService: InspectionsService) {}
|
||||||
|
|
||||||
|
@RequirePermission('inspections:read')
|
||||||
@Get(':id/inspections')
|
@Get(':id/inspections')
|
||||||
findByColony(@Param('id') id: string) {
|
findByColony(@Param('id') id: string) {
|
||||||
return this.inspectionsService.findByColony(id);
|
return this.inspectionsService.findByColony(id);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { LegacyRole as Role } from '../../generated/prisma';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateInspectionDto } from './dto/create-inspection.dto';
|
import { CreateInspectionDto } from './dto/create-inspection.dto';
|
||||||
@@ -15,17 +14,19 @@ import { InspectionsService } from './inspections.service';
|
|||||||
export class InspectionsController {
|
export class InspectionsController {
|
||||||
constructor(private readonly inspectionsService: InspectionsService) {}
|
constructor(private readonly inspectionsService: InspectionsService) {}
|
||||||
|
|
||||||
|
@RequirePermission('inspections:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.inspectionsService.findAll();
|
return this.inspectionsService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('inspections:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.inspectionsService.findById(id);
|
return this.inspectionsService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('inspections:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateInspectionDto,
|
@Body() dto: CreateInspectionDto,
|
||||||
@@ -34,7 +35,7 @@ export class InspectionsController {
|
|||||||
return this.inspectionsService.create(dto, actor.id);
|
return this.inspectionsService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('inspections:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -44,7 +45,7 @@ export class InspectionsController {
|
|||||||
return this.inspectionsService.update(id, dto, actor.id);
|
return this.inspectionsService.update(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('tasks:create')
|
||||||
@Post(':id/create-task')
|
@Post(':id/create-task')
|
||||||
createTask(
|
createTask(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import {
|
|||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { QueenStatus, LegacyRole as Role } from '../../generated/prisma';
|
import { QueenStatus } from '../../generated/prisma';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateQueenDto } from './dto/create-queen.dto';
|
import { CreateQueenDto } from './dto/create-queen.dto';
|
||||||
@@ -24,33 +24,37 @@ import { QueensService } from './queens.service';
|
|||||||
export class QueensController {
|
export class QueensController {
|
||||||
constructor(private readonly queensService: QueensService) {}
|
constructor(private readonly queensService: QueensService) {}
|
||||||
|
|
||||||
|
@RequirePermission('queens:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll(@Query('status') status?: QueenStatus) {
|
findAll(@Query('status') status?: QueenStatus) {
|
||||||
return this.queensService.findAll({ status });
|
return this.queensService.findAll({ status });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('queens:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.queensService.findById(id);
|
return this.queensService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('queens:read')
|
||||||
@Get(':id/history')
|
@Get(':id/history')
|
||||||
getHistory(@Param('id') id: string) {
|
getHistory(@Param('id') id: string) {
|
||||||
return this.queensService.getHistory(id);
|
return this.queensService.getHistory(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('queens:read')
|
||||||
@Get(':id/lineage')
|
@Get(':id/lineage')
|
||||||
getLineage(@Param('id') id: string) {
|
getLineage(@Param('id') id: string) {
|
||||||
return this.queensService.getLineage(id);
|
return this.queensService.getLineage(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('queens:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(@Body() dto: CreateQueenDto, @CurrentUser() actor: AuthenticatedUser) {
|
create(@Body() dto: CreateQueenDto, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.queensService.create(dto, actor.id);
|
return this.queensService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('queens:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -60,7 +64,7 @@ export class QueensController {
|
|||||||
return this.queensService.update(id, dto, actor.id);
|
return this.queensService.update(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('queens:assign')
|
||||||
@Post(':id/assign-colony')
|
@Post(':id/assign-colony')
|
||||||
assignColony(
|
assignColony(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -70,12 +74,13 @@ export class QueensController {
|
|||||||
return this.queensService.assignColony(id, dto, actor.id);
|
return this.queensService.assignColony(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('queens:read')
|
||||||
@Get(':id/evaluations')
|
@Get(':id/evaluations')
|
||||||
getEvaluations(@Param('id') id: string) {
|
getEvaluations(@Param('id') id: string) {
|
||||||
return this.queensService.getEvaluations(id);
|
return this.queensService.getEvaluations(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('queens:evaluate')
|
||||||
@Post(':id/evaluations')
|
@Post(':id/evaluations')
|
||||||
addEvaluation(
|
addEvaluation(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { LegacyRole as Role } from '../../generated/prisma';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateTaskTemplateDto } from './dto/create-task-template.dto';
|
import { CreateTaskTemplateDto } from './dto/create-task-template.dto';
|
||||||
@@ -10,21 +9,23 @@ import { TaskTemplatesService } from './task-templates.service';
|
|||||||
|
|
||||||
@ApiTags('task-templates')
|
@ApiTags('task-templates')
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
|
||||||
@Controller('task-templates')
|
@Controller('task-templates')
|
||||||
export class TaskTemplatesController {
|
export class TaskTemplatesController {
|
||||||
constructor(private readonly taskTemplatesService: TaskTemplatesService) {}
|
constructor(private readonly taskTemplatesService: TaskTemplatesService) {}
|
||||||
|
|
||||||
|
@RequirePermission('task-templates:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.taskTemplatesService.findAll();
|
return this.taskTemplatesService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('task-templates:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.taskTemplatesService.findById(id);
|
return this.taskTemplatesService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('task-templates:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateTaskTemplateDto,
|
@Body() dto: CreateTaskTemplateDto,
|
||||||
@@ -33,6 +34,7 @@ export class TaskTemplatesController {
|
|||||||
return this.taskTemplatesService.create(dto, actor.id);
|
return this.taskTemplatesService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('task-templates:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -42,6 +44,7 @@ export class TaskTemplatesController {
|
|||||||
return this.taskTemplatesService.update(id, dto, actor.id);
|
return this.taskTemplatesService.update(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('task-templates:deactivate')
|
||||||
@Post(':id/deactivate')
|
@Post(':id/deactivate')
|
||||||
deactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
deactivate(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.taskTemplatesService.deactivate(id, actor.id);
|
return this.taskTemplatesService.deactivate(id, actor.id);
|
||||||
|
|||||||
@@ -8,12 +8,8 @@ import {
|
|||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import {
|
import { TaskPriority, TaskStatus } from '../../generated/prisma';
|
||||||
LegacyRole as Role,
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
TaskPriority,
|
|
||||||
TaskStatus,
|
|
||||||
} from '../../generated/prisma';
|
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateTaskDto } from './dto/create-task.dto';
|
import { CreateTaskDto } from './dto/create-task.dto';
|
||||||
@@ -26,6 +22,7 @@ import { TasksService } from './tasks.service';
|
|||||||
export class TasksController {
|
export class TasksController {
|
||||||
constructor(private readonly tasksService: TasksService) {}
|
constructor(private readonly tasksService: TasksService) {}
|
||||||
|
|
||||||
|
@RequirePermission('tasks:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll(
|
findAll(
|
||||||
@Query('status') status?: TaskStatus,
|
@Query('status') status?: TaskStatus,
|
||||||
@@ -34,18 +31,19 @@ export class TasksController {
|
|||||||
return this.tasksService.findAll({ status, priority });
|
return this.tasksService.findAll({ status, priority });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('tasks:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.tasksService.findById(id);
|
return this.tasksService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('tasks:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(@Body() dto: CreateTaskDto, @CurrentUser() actor: AuthenticatedUser) {
|
create(@Body() dto: CreateTaskDto, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.tasksService.create(dto, actor.id);
|
return this.tasksService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('tasks:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@@ -55,7 +53,7 @@ export class TasksController {
|
|||||||
return this.tasksService.update(id, dto, actor.id);
|
return this.tasksService.update(id, dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('tasks:complete')
|
||||||
@Post(':id/complete')
|
@Post(':id/complete')
|
||||||
complete(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
complete(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||||
return this.tasksService.complete(id, actor.id);
|
return this.tasksService.complete(id, actor.id);
|
||||||
|
|||||||
Reference in new issue
Block a user