refactor(core): Mark all backend Enterprise Edition files and dirs (#12350)

This commit is contained in:
Iván Ovejero
2024-12-24 13:02:05 +01:00
committed by GitHub
parent 471d7b9420
commit f754b22a3f
194 changed files with 161 additions and 153 deletions

View File

@@ -0,0 +1,29 @@
import type { RequestHandler } from 'express';
import { Container } from 'typedi';
import { isSourceControlLicensed } from '../source-control-helper.ee';
import { SourceControlPreferencesService } from '../source-control-preferences.service.ee';
export const sourceControlLicensedAndEnabledMiddleware: RequestHandler = (_req, res, next) => {
const sourceControlPreferencesService = Container.get(SourceControlPreferencesService);
if (sourceControlPreferencesService.isSourceControlLicensedAndEnabled()) {
next();
} else {
if (!sourceControlPreferencesService.isSourceControlConnected()) {
res.status(412).json({
status: 'error',
message: 'source_control_not_connected',
});
} else {
res.status(401).json({ status: 'error', message: 'Unauthorized' });
}
}
};
export const sourceControlLicensedMiddleware: RequestHandler = (_req, res, next) => {
if (isSourceControlLicensed()) {
next();
} else {
res.status(401).json({ status: 'error', message: 'Unauthorized' });
}
};