Fix missing default value in configuration

pull/242/head
Clement Michaud 2018-08-05 16:02:56 +02:00
parent c82f910da3
commit 73be5bfc68
2 changed files with 5 additions and 2 deletions

View File

@ -24,14 +24,14 @@ export class ConfigurationParser {
const validationErrors = this.parseTypes(configuration); const validationErrors = this.parseTypes(configuration);
if (validationErrors.length > 0) { if (validationErrors.length > 0) {
validationErrors.forEach((e: string) => { console.log(e); }); validationErrors.forEach((e: string) => { console.log(e); });
throw new Error("Malformed configuration. Please double-check your configuration file."); throw new Error("Malformed configuration (schema). Please double-check your configuration file.");
} }
const [newConfiguration, completionErrors] = complete(configuration); const [newConfiguration, completionErrors] = complete(configuration);
if (completionErrors.length > 0) { if (completionErrors.length > 0) {
completionErrors.forEach((e: string) => { console.log(e); }); completionErrors.forEach((e: string) => { console.log(e); });
throw new Error("Malformed configuration. Please double-check your configuration file."); throw new Error("Malformed configuration (validator). Please double-check your configuration file.");
} }
return newConfiguration; return newConfiguration;
} }

View File

@ -28,6 +28,9 @@ export interface NotifierConfiguration {
export function complete(configuration: NotifierConfiguration): [NotifierConfiguration, string] { export function complete(configuration: NotifierConfiguration): [NotifierConfiguration, string] {
const newConfiguration: NotifierConfiguration = (configuration) ? JSON.parse(JSON.stringify(configuration)) : {}; const newConfiguration: NotifierConfiguration = (configuration) ? JSON.parse(JSON.stringify(configuration)) : {};
if (Object.keys(newConfiguration).length == 0)
newConfiguration.filesystem = { filename: '/tmp/authelia-notification.txt' };
const ERROR = "Notifier must have one of the following keys: 'filesystem', 'email' or 'smtp'"; const ERROR = "Notifier must have one of the following keys: 'filesystem', 'email' or 'smtp'";
if (Object.keys(newConfiguration).length != 1) if (Object.keys(newConfiguration).length != 1)