mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-03-30 05:27:03 +02:00
fix: OIDC configuration from YAML configuration file doesn't get loaded
This commit is contained in:
@@ -20,12 +20,12 @@ import { UserModule } from "./user/user.module";
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
ConfigModule,
|
||||||
AuthModule,
|
AuthModule,
|
||||||
ShareModule,
|
ShareModule,
|
||||||
FileModule,
|
FileModule,
|
||||||
EmailModule,
|
EmailModule,
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
ConfigModule,
|
|
||||||
JobsModule,
|
JobsModule,
|
||||||
UserModule,
|
UserModule,
|
||||||
ThrottlerModule.forRoot([
|
ThrottlerModule.forRoot([
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Global, Module } from "@nestjs/common";
|
import { Global, Module } from "@nestjs/common";
|
||||||
|
import { Config } from "@prisma/client";
|
||||||
import { EmailModule } from "src/email/email.module";
|
import { EmailModule } from "src/email/email.module";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { ConfigController } from "./config.controller";
|
import { ConfigController } from "./config.controller";
|
||||||
@@ -16,7 +17,15 @@ import { LogoService } from "./logo.service";
|
|||||||
},
|
},
|
||||||
inject: [PrismaService],
|
inject: [PrismaService],
|
||||||
},
|
},
|
||||||
ConfigService,
|
{
|
||||||
|
provide: ConfigService,
|
||||||
|
useFactory: async (prisma: PrismaService, configVariables: Config[]) => {
|
||||||
|
const configService = new ConfigService(configVariables, prisma);
|
||||||
|
await configService.initialize();
|
||||||
|
return configService;
|
||||||
|
},
|
||||||
|
inject: [PrismaService, "CONFIG_VARIABLES"],
|
||||||
|
},
|
||||||
LogoService,
|
LogoService,
|
||||||
],
|
],
|
||||||
controllers: [ConfigController],
|
controllers: [ConfigController],
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ export class ConfigService extends EventEmitter {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModuleInit() {
|
// Initialize gets called by the ConfigModule
|
||||||
|
async initialize() {
|
||||||
await this.loadYamlConfig();
|
await this.loadYamlConfig();
|
||||||
|
|
||||||
if (this.yamlConfig) {
|
if (this.yamlConfig) {
|
||||||
@@ -49,12 +50,13 @@ export class ConfigService extends EventEmitter {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.yamlConfig = yamlParse(configFile);
|
this.yamlConfig = yamlParse(configFile);
|
||||||
|
|
||||||
if (this.yamlConfig) {
|
if (this.yamlConfig) {
|
||||||
for (const configVariable of this.configVariables) {
|
for (const configVariable of this.configVariables) {
|
||||||
const category = this.yamlConfig[configVariable.category];
|
const category = this.yamlConfig[configVariable.category];
|
||||||
if (!category) continue;
|
if (!category) continue;
|
||||||
|
|
||||||
configVariable.value = category[configVariable.name];
|
configVariable.value = category[configVariable.name];
|
||||||
|
this.emit("update", configVariable.name, configVariable.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user