#1525 Triggere mailer for admin created accounts
This commit is contained in:
parent
986447335d
commit
21e13cb51e
11 changed files with 213 additions and 191 deletions
|
@ -11,11 +11,12 @@ import (
|
|||
)
|
||||
|
||||
type AdminCrateUserForm struct {
|
||||
LoginType string `binding:"Required"`
|
||||
LoginName string
|
||||
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
|
||||
Email string `binding:"Required;Email;MaxSize(254)"`
|
||||
Password string `binding:"MaxSize(255)"`
|
||||
LoginType string `binding:"Required"`
|
||||
LoginName string
|
||||
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
|
||||
Email string `binding:"Required;Email;MaxSize(254)"`
|
||||
Password string `binding:"MaxSize(255)"`
|
||||
SendNotify bool
|
||||
}
|
||||
|
||||
func (f *AdminCrateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -17,10 +17,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
AUTH_ACTIVATE base.TplName = "mail/auth/activate"
|
||||
AUTH_ACTIVATE_EMAIL base.TplName = "mail/auth/activate_email"
|
||||
AUTH_RESET_PASSWORD base.TplName = "mail/auth/reset_passwd"
|
||||
AUTH_REGISTER_SUCCESS base.TplName = "mail/auth/register_success"
|
||||
AUTH_ACTIVATE base.TplName = "mail/auth/activate"
|
||||
AUTH_ACTIVATE_EMAIL base.TplName = "mail/auth/activate_email"
|
||||
AUTH_REGISTER_NOTIFY base.TplName = "mail/auth/register_notify"
|
||||
AUTH_RESET_PASSWORD base.TplName = "mail/auth/reset_passwd"
|
||||
|
||||
NOTIFY_COLLABORATOR base.TplName = "mail/notify/collaborator"
|
||||
NOTIFY_MENTION base.TplName = "mail/notify/mention"
|
||||
|
@ -64,6 +64,20 @@ func SendResetPasswordMail(c *macaron.Context, u *models.User) {
|
|||
SendUserMail(c, u, AUTH_RESET_PASSWORD, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password")
|
||||
}
|
||||
|
||||
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
|
||||
func SendRegisterNotifyMail(c *macaron.Context, u *models.User) {
|
||||
body, err := c.HTMLString(string(AUTH_REGISTER_NOTIFY), ComposeTplData(u))
|
||||
if err != nil {
|
||||
log.Error(4, "HTMLString: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMessage([]string{u.Email}, c.Tr("mail.register_notify"), body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, registration notify", u.Id)
|
||||
|
||||
SendAsync(msg)
|
||||
}
|
||||
|
||||
// SendActivateAccountMail sends confirmation e-mail.
|
||||
func SendActivateEmailMail(c *macaron.Context, u *models.User, email *models.EmailAddress) {
|
||||
data := ComposeTplData(u)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue