mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
828f565290
This is going to be the v4. Expected improvements: - More reliable due to static typing. - Bump of performance. - Improvement of logging. - Authelia can be shipped as a single binary. - Will likely work on ARM architecture.
34 lines
805 B
Go
34 lines
805 B
Go
package notification
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"time"
|
|
|
|
"github.com/clems4ever/authelia/configuration/schema"
|
|
)
|
|
|
|
// FileNotifier a notifier to send emails to SMTP servers.
|
|
type FileNotifier struct {
|
|
path string
|
|
}
|
|
|
|
// NewFileNotifier create an FileNotifier writing the notification into a file.
|
|
func NewFileNotifier(configuration schema.FileSystemNotifierConfiguration) *FileNotifier {
|
|
return &FileNotifier{
|
|
path: configuration.Filename,
|
|
}
|
|
}
|
|
|
|
// Send send a identity verification link to a user.
|
|
func (n *FileNotifier) Send(recipient string, subject string, body string) error {
|
|
content := fmt.Sprintf("Date: %s\nRecipient: %s\nSubject: %s\nBody: %s", time.Now(), recipient, subject, body)
|
|
|
|
err := ioutil.WriteFile(n.path, []byte(content), 0755)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|