Browse Source

Check primary email address fields on CreateUser (#556)

* Check primary email address fields on CreateUser

As this check wasn't available, uid=1 (and possibly guests too, if registration is open) is able to register new users with existing email addresses. This leads to numerous 500 errors.

* Update user.go

* Lower the email first. Then check
tags/v1.1.0
Berk Demirkır 7 years ago
parent
commit
bdad3b259a
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      models/user.go

+ 9
- 0
models/user.go View File

@@ -600,6 +600,15 @@ func CreateUser(u *User) (err error) {
}

u.Email = strings.ToLower(u.Email)
has, err := x.
Where("email=?", u.Email).
Get(new(User))
if err != nil {
return err
} else if has {
return ErrEmailAlreadyUsed{u.Email}
}

isExist, err = IsEmailUsed(u.Email)
if err != nil {
return err

Loading…
Cancel
Save