fix: validate email address when creating a user via cli

This commit is contained in:
kolaente 2022-03-04 19:58:40 +01:00
parent 21541bc118
commit 75f74b429e
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -24,6 +24,8 @@ import (
"strings"
"time"
"github.com/asaskevich/govalidator"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/initialize"
"code.vikunja.io/api/pkg/log"
@ -175,6 +177,11 @@ var userCreateCmd = &cobra.Command{
Email: userFlagEmail,
Password: getPasswordFromFlagOrInput(),
}
if !govalidator.IsEmail(userFlagEmail) {
log.Fatalf("Provided email is invalid.")
}
newUser, err := user.CreateUser(s, u)
if err != nil {
_ = s.Rollback()