feat(signup): progress on new sign up and email verification flow, #2353

This commit is contained in:
Torkel Ödegaard
2015-08-28 13:45:16 +02:00
parent 24dfa55465
commit c61b22cefb
9 changed files with 279 additions and 31 deletions
+9 -5
View File
@@ -3,7 +3,9 @@ package notifications
import (
"bytes"
"errors"
"fmt"
"html/template"
"net/url"
"path/filepath"
"github.com/grafana/grafana/pkg/bus"
@@ -16,7 +18,7 @@ import (
var mailTemplates *template.Template
var tmplResetPassword = "reset_password.html"
var tmplWelcomeOnSignUp = "welcome_on_signup.html"
var tmplSignUpStarted = "signup_started.html"
func Init() error {
initMailQueue()
@@ -121,17 +123,19 @@ func validateResetPasswordCode(query *m.ValidateResetPasswordCodeQuery) error {
}
func signUpStartedHandler(evt *events.SignUpStarted) error {
log.Info("User signed up: %s, send_option: %s", evt.Email, setting.Smtp.SendWelcomeEmailOnSignUp)
log.Info("User signup started: %s", evt.Email)
if evt.Email == "" || !setting.Smtp.SendWelcomeEmailOnSignUp {
if evt.Email == "" {
return nil
}
return sendEmailCommandHandler(&m.SendEmailCommand{
To: []string{evt.Email},
Template: tmplWelcomeOnSignUp,
Template: tmplSignUpStarted,
Data: map[string]interface{}{
"Email": evt.Email,
"Email": evt.Email,
"Code": evt.Code,
"SignUpUrl": setting.ToAbsUrl(fmt.Sprintf("signup/?email=%s&code=%s", url.QueryEscape(evt.Email), url.QueryEscape(evt.Code))),
},
})
}