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!

bad fixed

kruzhambuse0bb195b8a04
diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts
index 329a11607..f7b916f0f 100644
--- a/src/user/user.controller.ts
+++ b/src/user/user.controller.ts
@@ -94,6 +94,22 @@ export class UserController {
}
}
+ @Delete('/api-key')
+ @UseGuards(RolesGuard)
+ @UseGuards(SelfhostedGuard)
+ @Roles(UserType.CUSTOMER, UserType.ADMIN)
+ async deleteApiKey(@CurrentUserId() userId: string): Promise<void> {
+ this.logger.log({ userId }, 'DELETE /user/api-key')
+
+ const user = await this.userService.findOne(userId)
+
+ if (_isNull(user.apiKey)) {
+ throw new ConflictException("You don't have an API key")
+ }
+
+ await this.userService.update(userId, { apiKey: null })
+ }
+
@Delete('/:id')
@HttpCode(204)
@UseGuards(RolesGuard)
@@ -358,8 +374,9 @@ export class UserController {
return user
}
- @Post('api-key')
+ @Post('/api-key')
@UseGuards(RolesGuard)
+ @UseGuards(SelfhostedGuard)
@Roles(UserType.CUSTOMER, UserType.ADMIN)
async generateApiKey(@CurrentUserId() userId: string): Promise<{
apiKey: string
@@ -379,18 +396,4 @@ export class UserController {
return { apiKey }
}
- @Delete('api-key')
- @UseGuards(RolesGuard)
- @Roles(UserType.CUSTOMER, UserType.ADMIN)
- async deleteApiKey(@CurrentUserId() userId: string): Promise<void> {
- this.logger.log({ userId }, 'DELETE /user/api-key')
-
- const user = await this.userService.findOne(userId)
-
- if (_isNull(user.apiKey)) {
- throw new ConflictException("You don't have an API key")
- }
-
- await this.userService.update(userId, { apiKey: null })
- }
}