From 1979eb8a9c27e096dc7d7b54d7a00f55fd9185e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 9 Mar 2023 16:24:44 +0100 Subject: [PATCH] fix(core): Fix issues with LDAP reset and LDAP init (no-changelog) (#5657) * fix(core): Ldap reset should recreate the default config * fix(core): init ldap before registering the routes for it --- packages/cli/src/commands/ldap/reset.ts | 7 ++++++- packages/cli/src/commands/start.ts | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/ldap/reset.ts b/packages/cli/src/commands/ldap/reset.ts index 7b555fc52e..db276c40c1 100644 --- a/packages/cli/src/commands/ldap/reset.ts +++ b/packages/cli/src/commands/ldap/reset.ts @@ -1,5 +1,5 @@ import * as Db from '@/Db'; -import { LDAP_FEATURE_NAME } from '@/Ldap/constants'; +import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/Ldap/constants'; import { In } from 'typeorm'; import { BaseCommand } from '../BaseCommand'; @@ -17,6 +17,11 @@ export class Reset extends BaseCommand { await AuthIdentity.delete({ providerType: 'ldap' }); await User.delete({ id: In(ldapIdentities.map((i) => i.userId)) }); await Settings.delete({ key: LDAP_FEATURE_NAME }); + await Settings.insert({ + key: LDAP_FEATURE_NAME, + value: JSON.stringify(LDAP_DEFAULT_CONFIGURATION), + loadOnStartup: true, + }); this.logger.info('Successfully reset the database to default ldap state.'); } diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index ada08e48ec..bac95bfe3c 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -326,13 +326,13 @@ export class Start extends BaseCommand { ); } + await handleLdapInit(); + await Server.start(); // Start to get active workflows and run their triggers await this.activeWorkflowRunner.init(); - await handleLdapInit(); - const editorUrl = GenericHelpers.getBaseUrl(); this.log(`\nEditor is now accessible via:\n${editorUrl}`);