mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-03-26 11:13:25 +01: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({
|
||||
imports: [
|
||||
ConfigModule,
|
||||
AuthModule,
|
||||
ShareModule,
|
||||
FileModule,
|
||||
EmailModule,
|
||||
PrismaModule,
|
||||
ConfigModule,
|
||||
JobsModule,
|
||||
UserModule,
|
||||
ThrottlerModule.forRoot([
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Global, Module } from "@nestjs/common";
|
||||
import { Config } from "@prisma/client";
|
||||
import { EmailModule } from "src/email/email.module";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { ConfigController } from "./config.controller";
|
||||
@@ -16,7 +17,15 @@ import { LogoService } from "./logo.service";
|
||||
},
|
||||
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,
|
||||
],
|
||||
controllers: [ConfigController],
|
||||
|
||||
@@ -30,7 +30,8 @@ export class ConfigService extends EventEmitter {
|
||||
super();
|
||||
}
|
||||
|
||||
async onModuleInit() {
|
||||
// Initialize gets called by the ConfigModule
|
||||
async initialize() {
|
||||
await this.loadYamlConfig();
|
||||
|
||||
if (this.yamlConfig) {
|
||||
@@ -49,12 +50,13 @@ export class ConfigService extends EventEmitter {
|
||||
}
|
||||
try {
|
||||
this.yamlConfig = yamlParse(configFile);
|
||||
|
||||
if (this.yamlConfig) {
|
||||
for (const configVariable of this.configVariables) {
|
||||
const category = this.yamlConfig[configVariable.category];
|
||||
if (!category) continue;
|
||||
|
||||
configVariable.value = category[configVariable.name];
|
||||
this.emit("update", configVariable.name, configVariable.value);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user