mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
refactor(core): Make Logger a service (no-changelog) (#7494)
This commit is contained in:
committed by
GitHub
parent
db4e61ba24
commit
05586a900d
@@ -1,5 +1,5 @@
|
||||
import express from 'express';
|
||||
import { LoggerProxy } from 'n8n-workflow';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
import * as ResponseHelper from '@/ResponseHelper';
|
||||
import type { VariablesRequest } from '@/requests';
|
||||
@@ -9,14 +9,11 @@ import {
|
||||
VariablesValidationError,
|
||||
} from './variables.service.ee';
|
||||
import { isVariablesEnabled } from './enviromentHelpers';
|
||||
import Container from 'typedi';
|
||||
import { Logger } from '@/Logger';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const EEVariablesController = express.Router();
|
||||
|
||||
/**
|
||||
* Initialize Logger if needed
|
||||
*/
|
||||
EEVariablesController.use((req, res, next) => {
|
||||
if (!isVariablesEnabled()) {
|
||||
next('router');
|
||||
@@ -30,9 +27,12 @@ EEVariablesController.post(
|
||||
'/',
|
||||
ResponseHelper.send(async (req: VariablesRequest.Create) => {
|
||||
if (req.user.globalRole.name !== 'owner') {
|
||||
LoggerProxy.info('Attempt to update a variable blocked due to lack of permissions', {
|
||||
userId: req.user.id,
|
||||
});
|
||||
Container.get(Logger).info(
|
||||
'Attempt to update a variable blocked due to lack of permissions',
|
||||
{
|
||||
userId: req.user.id,
|
||||
},
|
||||
);
|
||||
throw new ResponseHelper.AuthError('Unauthorized');
|
||||
}
|
||||
const variable = req.body;
|
||||
@@ -55,10 +55,13 @@ EEVariablesController.patch(
|
||||
ResponseHelper.send(async (req: VariablesRequest.Update) => {
|
||||
const id = req.params.id;
|
||||
if (req.user.globalRole.name !== 'owner') {
|
||||
LoggerProxy.info('Attempt to update a variable blocked due to lack of permissions', {
|
||||
id,
|
||||
userId: req.user.id,
|
||||
});
|
||||
Container.get(Logger).info(
|
||||
'Attempt to update a variable blocked due to lack of permissions',
|
||||
{
|
||||
id,
|
||||
userId: req.user.id,
|
||||
},
|
||||
);
|
||||
throw new ResponseHelper.AuthError('Unauthorized');
|
||||
}
|
||||
const variable = req.body;
|
||||
|
||||
Reference in New Issue
Block a user