Final work password reset email, Closes #1456

This commit is contained in:
Torkel Ödegaard 2015-06-08 18:25:04 +02:00
parent 95fd34ed14
commit bb2d810709
4 changed files with 8 additions and 2 deletions

View File

@ -188,6 +188,7 @@ from_address = admin@grafana.localhost
[emails]
welcome_email_on_sign_up = false
templates_pattern = emails/*.html
#################################### Logging ##########################
[log]

View File

@ -32,7 +32,7 @@ func Init() error {
"Subject": subjectTemplateFunc,
})
templatePattern := filepath.Join(setting.StaticRootPath, "emails/*.html")
templatePattern := filepath.Join(setting.StaticRootPath, setting.Smtp.TemplatesPattern)
_, err := mailTemplates.ParseGlob(templatePattern)
if err != nil {
return err

View File

@ -15,6 +15,8 @@ func TestNotifications(t *testing.T) {
bus.ClearBusHandlers()
setting.StaticRootPath = "../../../public/"
setting.Smtp.Enabled = true
setting.Smtp.TemplatesPattern = "emails/*.html"
setting.Smtp.FromAddress = "from@address.com"
err := Init()
@ -26,7 +28,8 @@ func TestNotifications(t *testing.T) {
}
Convey("When sending reset email password", func() {
sendResetPasswordEmail(&m.SendResetPasswordEmailCommand{User: &m.User{Email: "asd@asd.com"}})
err := sendResetPasswordEmail(&m.SendResetPasswordEmailCommand{User: &m.User{Email: "asd@asd.com"}})
So(err, ShouldBeNil)
So(sentMsg.Body, ShouldContainSubstring, "body")
So(sentMsg.Subject, ShouldEqual, "Reset your Grafana password")
So(sentMsg.Body, ShouldNotContainSubstring, "Subject")

View File

@ -11,6 +11,7 @@ type SmtpSettings struct {
SkipVerify bool
SendWelcomeEmailOnSignUp bool
TemplatesPattern string
}
func readSmtpSettings() {
@ -26,4 +27,5 @@ func readSmtpSettings() {
emails := Cfg.Section("emails")
Smtp.SendWelcomeEmailOnSignUp = emails.Key("welcome_email_on_sign_up").MustBool(false)
Smtp.TemplatesPattern = emails.Key("templates_pattern").MustString("emails/*.html")
}