diff options
Diffstat (limited to 'models/user/user.go')
-rw-r--r-- | models/user/user.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/models/user/user.go b/models/user/user.go index 3eabf4808c..a3094a13ce 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -644,6 +644,15 @@ func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err e u.Visibility = overwriteDefault[0].Visibility } + // validate data + if err := validateUser(u); err != nil { + return err + } + + if err := ValidateEmail(u.Email); err != nil { + return err + } + ctx, committer, err := db.TxContext() if err != nil { return err @@ -652,11 +661,6 @@ func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err e sess := db.GetEngine(ctx) - // validate data - if err := validateUser(u); err != nil { - return err - } - isExist, err := isUserExist(sess, 0, u.Name) if err != nil { return err |