mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat: Add initial scope checks via decorators (#7737)
This commit is contained in:
@@ -3,7 +3,7 @@ import { In, Not } from 'typeorm';
|
||||
import { User } from '@db/entities/User';
|
||||
import { SharedCredentials } from '@db/entities/SharedCredentials';
|
||||
import { SharedWorkflow } from '@db/entities/SharedWorkflow';
|
||||
import { Authorized, Delete, Get, RestController, Patch } from '@/decorators';
|
||||
import { RequireGlobalScope, Authorized, Delete, Get, RestController, Patch } from '@/decorators';
|
||||
import { ListQuery, UserRequest, UserSettingsUpdatePayload } from '@/requests';
|
||||
import { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
|
||||
import { IExternalHooksClass, IInternalHooksClass } from '@/Interfaces';
|
||||
@@ -114,8 +114,8 @@ export class UsersController {
|
||||
return publicUsers;
|
||||
}
|
||||
|
||||
@Authorized('any')
|
||||
@Get('/', { middlewares: listQueryMiddleware })
|
||||
@RequireGlobalScope('user:list')
|
||||
async listUsers(req: ListQuery.Request) {
|
||||
const { listQueryOptions } = req;
|
||||
|
||||
@@ -132,8 +132,8 @@ export class UsersController {
|
||||
: publicUsers;
|
||||
}
|
||||
|
||||
@Authorized(['global', 'owner'])
|
||||
@Get('/:id/password-reset-link')
|
||||
@RequireGlobalScope('user:resetPassword')
|
||||
async getUserPasswordResetLink(req: UserRequest.PasswordResetLink) {
|
||||
const user = await this.userService.findOneOrFail({
|
||||
where: { id: req.params.id },
|
||||
@@ -146,8 +146,8 @@ export class UsersController {
|
||||
return { link };
|
||||
}
|
||||
|
||||
@Authorized(['global', 'owner'])
|
||||
@Patch('/:id/settings')
|
||||
@RequireGlobalScope('user:update')
|
||||
async updateUserSettings(req: UserRequest.UserSettingsUpdate) {
|
||||
const payload = plainToInstance(UserSettingsUpdatePayload, req.body);
|
||||
|
||||
@@ -168,6 +168,7 @@ export class UsersController {
|
||||
*/
|
||||
@Authorized(['global', 'owner'])
|
||||
@Delete('/:id')
|
||||
@RequireGlobalScope('user:delete')
|
||||
async deleteUser(req: UserRequest.Delete) {
|
||||
const { id: idToDelete } = req.params;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user