mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor: Remove pre-setup prompt on owner setup (#6495)
This commit is contained in:
committed by
कारतोफ्फेलस्क्रिप्ट™
parent
0287d5becd
commit
abe7f71627
@@ -1,6 +1,6 @@
|
||||
import validator from 'validator';
|
||||
import { validateEntity } from '@/GenericHelpers';
|
||||
import { Authorized, Get, Post, RestController } from '@/decorators';
|
||||
import { Authorized, Post, RestController } from '@/decorators';
|
||||
import { BadRequestError } from '@/ResponseHelper';
|
||||
import {
|
||||
hashPassword,
|
||||
@@ -13,12 +13,7 @@ import type { ILogger } from 'n8n-workflow';
|
||||
import type { Config } from '@/config';
|
||||
import { OwnerRequest } from '@/requests';
|
||||
import type { IDatabaseCollections, IInternalHooksClass } from '@/Interfaces';
|
||||
import type {
|
||||
CredentialsRepository,
|
||||
SettingsRepository,
|
||||
UserRepository,
|
||||
WorkflowRepository,
|
||||
} from '@db/repositories';
|
||||
import type { SettingsRepository, UserRepository } from '@db/repositories';
|
||||
|
||||
@Authorized(['global', 'owner'])
|
||||
@RestController('/owner')
|
||||
@@ -33,10 +28,6 @@ export class OwnerController {
|
||||
|
||||
private readonly settingsRepository: SettingsRepository;
|
||||
|
||||
private readonly credentialsRepository: CredentialsRepository;
|
||||
|
||||
private readonly workflowsRepository: WorkflowRepository;
|
||||
|
||||
constructor({
|
||||
config,
|
||||
logger,
|
||||
@@ -46,28 +37,13 @@ export class OwnerController {
|
||||
config: Config;
|
||||
logger: ILogger;
|
||||
internalHooks: IInternalHooksClass;
|
||||
repositories: Pick<IDatabaseCollections, 'User' | 'Settings' | 'Credentials' | 'Workflow'>;
|
||||
repositories: Pick<IDatabaseCollections, 'User' | 'Settings'>;
|
||||
}) {
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
this.internalHooks = internalHooks;
|
||||
this.userRepository = repositories.User;
|
||||
this.settingsRepository = repositories.Settings;
|
||||
this.credentialsRepository = repositories.Credentials;
|
||||
this.workflowsRepository = repositories.Workflow;
|
||||
}
|
||||
|
||||
@Get('/pre-setup')
|
||||
async preSetup(): Promise<{ credentials: number; workflows: number }> {
|
||||
if (this.config.getEnv('userManagement.isInstanceOwnerSetUp')) {
|
||||
throw new BadRequestError('Instance owner already setup');
|
||||
}
|
||||
|
||||
const [credentials, workflows] = await Promise.all([
|
||||
this.credentialsRepository.countBy({}),
|
||||
this.workflowsRepository.countBy({}),
|
||||
]);
|
||||
return { credentials, workflows };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user