Revert "chore(core): Use roles from database in global roles (#17853)" (#18738)

This commit is contained in:
Andreas Fitzek
2025-08-25 14:29:28 +02:00
committed by GitHub
parent b62c957c71
commit a21a03d4b0
117 changed files with 410 additions and 875 deletions

View File

@@ -33,7 +33,7 @@ export class ApiKeysController {
_res: Response,
@Body body: CreateApiKeyRequestDto,
) {
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user, body.scopes)) {
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user.role, body.scopes)) {
throw new BadRequestError('Invalid scopes for user role');
}
@@ -80,7 +80,7 @@ export class ApiKeysController {
@Param('id') apiKeyId: string,
@Body body: UpdateApiKeyRequestDto,
) {
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user, body.scopes)) {
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user.role, body.scopes)) {
throw new BadRequestError('Invalid scopes for user role');
}
@@ -91,7 +91,8 @@ export class ApiKeysController {
@Get('/scopes', { middlewares: [isApiEnabledMiddleware] })
async getApiKeyScopes(req: AuthenticatedRequest, _res: Response) {
const scopes = getApiKeyScopesForRole(req.user);
const { role } = req.user;
const scopes = getApiKeyScopesForRole(role);
return scopes;
}
}