Move sending confirmation email to separate function
This commit is contained in:
parent
c90328896a
commit
36b9a9b2d5
|
@ -76,19 +76,11 @@ func CreateUser(user *User) (newUser *User, err error) {
|
||||||
return &User{}, err
|
return &User{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dont send a mail if no mailer is configured
|
err = sendConfirmEmail(user)
|
||||||
if !config.MailerEnabled.GetBool() {
|
if err != nil {
|
||||||
return newUserOut, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the user a mail with a link to confirm the mail
|
|
||||||
data := map[string]interface{}{
|
|
||||||
"User": newUserOut,
|
|
||||||
"IsNew": true,
|
|
||||||
}
|
|
||||||
|
|
||||||
mail.SendMailWithTemplate(user.Email, newUserOut.Username+" + Vikunja = <3", "confirm-email", data)
|
|
||||||
|
|
||||||
return newUserOut, err
|
return newUserOut, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,3 +141,20 @@ func checkIfUserExists(user *User) (err error) {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendConfirmEmail(user *User) error {
|
||||||
|
// Dont send a mail if no mailer is configured
|
||||||
|
if !config.MailerEnabled.GetBool() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the user a mail with a link to confirm the mail
|
||||||
|
data := map[string]interface{}{
|
||||||
|
"User": user,
|
||||||
|
"IsNew": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
mail.SendMailWithTemplate(user.Email, user.Username+" + Vikunja = <3", "confirm-email", data)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user