fix: validate email address when creating a user via cli
This commit is contained in:
parent
21541bc118
commit
75f74b429e
1 changed files with 7 additions and 0 deletions
|
@ -24,6 +24,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/asaskevich/govalidator"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/db"
|
"code.vikunja.io/api/pkg/db"
|
||||||
"code.vikunja.io/api/pkg/initialize"
|
"code.vikunja.io/api/pkg/initialize"
|
||||||
"code.vikunja.io/api/pkg/log"
|
"code.vikunja.io/api/pkg/log"
|
||||||
|
@ -175,6 +177,11 @@ var userCreateCmd = &cobra.Command{
|
||||||
Email: userFlagEmail,
|
Email: userFlagEmail,
|
||||||
Password: getPasswordFromFlagOrInput(),
|
Password: getPasswordFromFlagOrInput(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !govalidator.IsEmail(userFlagEmail) {
|
||||||
|
log.Fatalf("Provided email is invalid.")
|
||||||
|
}
|
||||||
|
|
||||||
newUser, err := user.CreateUser(s, u)
|
newUser, err := user.CreateUser(s, u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = s.Rollback()
|
_ = s.Rollback()
|
||||||
|
|
Loading…
Reference in a new issue