diff --git a/pkg/user/user_create.go b/pkg/user/user_create.go index cdc15864a..a692f5991 100644 --- a/pkg/user/user_create.go +++ b/pkg/user/user_create.go @@ -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 +}