Move sending confirmation email to separate function

This commit is contained in:
kolaente 2020-11-19 21:10:47 +01:00
parent c90328896a
commit 36b9a9b2d5
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 20 additions and 11 deletions

View File

@ -76,19 +76,11 @@ func CreateUser(user *User) (newUser *User, err error) {
return &User{}, err
}
// Dont send a mail if no mailer is configured
if !config.MailerEnabled.GetBool() {
return newUserOut, err
err = sendConfirmEmail(user)
if err != nil {
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
}
@ -149,3 +141,20 @@ func checkIfUserExists(user *User) (err error) {
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
}