Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

implemented share reject/removal for users

Blue Mouse5dc25fc9461a
diff --git a/src/project/project.service.ts b/src/project/project.service.ts
index 14baf664e..30d53d98e 100644
--- a/src/project/project.service.ts
+++ b/src/project/project.service.ts
@@ -70,6 +70,7 @@ export class ProjectService {
async deleteMultiple(pids: string[]): Promise<any> {
return this.projectsRepository.createQueryBuilder()
.delete()
+ // TODO: !!! Enforce Prepared Statements and Parameterization
.where(`id IN (${pids})`)
.execute()
}
diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts
index 6dff23116..fb0d95d42 100644
--- a/src/user/user.controller.ts
+++ b/src/user/user.controller.ts
@@ -180,12 +180,20 @@ export class UserController {
where: {
id: shareId,
},
- relations: ['project'],
+ relations: ['user'],
})
- // Todo:
- // 1. Validate if uid can access this share
- // 2. Delete share
+ if (_isEmpty(share)) {
+ throw new BadRequestException('The provided share id is not valid')
+ }
+
+ if (share[0]?.user?.id !== uid) {
+ throw new BadRequestException('You are not allowed to delete this share')
+ }
+
+ await this.projectService.deleteShare(shareId)
+
+ return 'shareDeleted'
}
@Post('/confirm_email')