mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
chore(core): Use roles from database in global roles (#17853)
This commit is contained in:
@@ -33,7 +33,7 @@ export class ApiKeysController {
|
||||
_res: Response,
|
||||
@Body body: CreateApiKeyRequestDto,
|
||||
) {
|
||||
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user.role, body.scopes)) {
|
||||
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user, 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.role, body.scopes)) {
|
||||
if (!this.publicApiKeyService.apiKeyHasValidScopesForRole(req.user, body.scopes)) {
|
||||
throw new BadRequestError('Invalid scopes for user role');
|
||||
}
|
||||
|
||||
@@ -91,8 +91,7 @@ export class ApiKeysController {
|
||||
|
||||
@Get('/scopes', { middlewares: [isApiEnabledMiddleware] })
|
||||
async getApiKeyScopes(req: AuthenticatedRequest, _res: Response) {
|
||||
const { role } = req.user;
|
||||
const scopes = getApiKeyScopesForRole(role);
|
||||
const scopes = getApiKeyScopesForRole(req.user);
|
||||
return scopes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user