Make file system an available notifier option for testing purpose
parent
26418278bc
commit
346c559141
|
@ -182,6 +182,10 @@ storage:
|
||||||
# registration or a TOTP registration.
|
# registration or a TOTP registration.
|
||||||
# Use only an available configuration: filesystem, gmail
|
# Use only an available configuration: filesystem, gmail
|
||||||
notifier:
|
notifier:
|
||||||
|
# For testing purpose, notifications can be sent in a file
|
||||||
|
# filesystem:
|
||||||
|
# filename: /tmp/authelia/notification.txt
|
||||||
|
|
||||||
# Use your gmail account to send the notifications. You can use an app password.
|
# Use your gmail account to send the notifications. You can use an app password.
|
||||||
# gmail:
|
# gmail:
|
||||||
# username: user@example.com
|
# username: user@example.com
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import * as BluebirdPromise from "bluebird";
|
||||||
|
import * as util from "util";
|
||||||
|
import * as Fs from "fs";
|
||||||
|
import { INotifier } from "./INotifier";
|
||||||
|
import { Identity } from "../../../types/Identity";
|
||||||
|
|
||||||
|
import { FileSystemNotifierConfiguration } from "../configuration/Configuration";
|
||||||
|
|
||||||
|
export class FileSystemNotifier implements INotifier {
|
||||||
|
private filename: string;
|
||||||
|
|
||||||
|
constructor(options: FileSystemNotifierConfiguration) {
|
||||||
|
this.filename = options.filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
notify(identity: Identity, subject: string, link: string): BluebirdPromise<void> {
|
||||||
|
const content = util.format("Date: %s\nUser: %s\nSubject: %s\nLink: %s", new Date().toString(), identity.userid,
|
||||||
|
subject, link);
|
||||||
|
const writeFilePromised: any = BluebirdPromise.promisify(Fs.writeFile);
|
||||||
|
return writeFilePromised(this.filename, content);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { NotifierConfiguration } from "../configuration/Configuration";
|
||||||
import { Nodemailer } from "../../../types/Dependencies";
|
import { Nodemailer } from "../../../types/Dependencies";
|
||||||
import { INotifier } from "./INotifier";
|
import { INotifier } from "./INotifier";
|
||||||
|
|
||||||
|
import { FileSystemNotifier } from "./FileSystemNotifier";
|
||||||
import { GMailNotifier } from "./GMailNotifier";
|
import { GMailNotifier } from "./GMailNotifier";
|
||||||
import { SmtpNotifier } from "./SmtpNotifier";
|
import { SmtpNotifier } from "./SmtpNotifier";
|
||||||
|
|
||||||
|
@ -14,6 +15,9 @@ export class NotifierFactory {
|
||||||
else if ("smtp" in options) {
|
else if ("smtp" in options) {
|
||||||
return new SmtpNotifier(options.smtp, nodemailer);
|
return new SmtpNotifier(options.smtp, nodemailer);
|
||||||
}
|
}
|
||||||
|
else if ("filesystem" in options) {
|
||||||
|
return new FileSystemNotifier(options.filesystem);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("No available notifier option detected.");
|
throw new Error("No available notifier option detected.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue