diff options
author | Berk Demirkır <bdemirkir@users.noreply.github.com> | 2017-01-05 02:52:20 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-05 08:52:20 +0800 |
commit | bdad3b259aab7ac78b9def5bf4fafac880d0301f (patch) | |
tree | eb57a067e8f301b4e07eb1900476d860962e1a9f /models/user.go | |
parent | 1207bda94b8de9f0cc618c4ccce235d809a5559e (diff) | |
download | gitea-bdad3b259aab7ac78b9def5bf4fafac880d0301f.tar.gz gitea-bdad3b259aab7ac78b9def5bf4fafac880d0301f.zip |
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
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go index e32a29ae31..1dbd63dce0 100644 --- a/models/user.go +++ b/models/user.go @@ -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 |