diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-30 18:29:16 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-30 18:29:16 -0500 |
commit | 533880860069ca95fba44732721fef3434e1ec99 (patch) | |
tree | 31b69d9b64d76295df8beb6ec0966b963f378da4 /models | |
parent | 82da024a4df2a626633a49f70dd3a2889b525d15 (diff) | |
download | gitea-533880860069ca95fba44732721fef3434e1ec99.tar.gz gitea-533880860069ca95fba44732721fef3434e1ec99.zip |
fix #676
Diffstat (limited to 'models')
-rw-r--r-- | models/user.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go index 61a43ba9bf..5c6101e62c 100644 --- a/models/user.go +++ b/models/user.go @@ -417,6 +417,13 @@ func ChangeUserName(u *User, newUserName string) (err error) { // UpdateUser updates user's information. func UpdateUser(u *User) error { + has, err := x.Where("id != ?", u.Id).And("email = ?", u.Email).Get(new(User)) + if err != nil { + return err + } else if has { + return ErrEmailAlreadyUsed + } + u.LowerName = strings.ToLower(u.Name) if len(u.Location) > 255 { @@ -429,7 +436,7 @@ func UpdateUser(u *User) error { u.Description = u.Description[:255] } - _, err := x.Id(u.Id).AllCols().Update(u) + _, err = x.Id(u.Id).AllCols().Update(u) return err } |