From 207960b459d635667226d2d78f11ef3279ba9cc7 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 29 Jan 2017 18:29:53 -0500 Subject: [PATCH] Fix create user can use user email which is used (#4016) --- gogs.go | 2 +- models/user_mail.go | 10 +++++++++- templates/.VERSION | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gogs.go b/gogs.go index 8a9bc5235..525f1243a 100644 --- a/gogs.go +++ b/gogs.go @@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.9.125.0128" +const APP_VER = "0.9.126.0129" func init() { setting.AppVer = APP_VER diff --git a/models/user_mail.go b/models/user_mail.go index b9b210f49..4c6efd423 100644 --- a/models/user_mail.go +++ b/models/user_mail.go @@ -58,7 +58,15 @@ func isEmailUsed(e Engine, email string) (bool, error) { return true, nil } - return e.Get(&EmailAddress{Email: email}) + has, err := e.Get(&EmailAddress{Email: email}) + if err != nil { + return false, err + } else if has { + return true, nil + } + + // We need to check primary email of users as well. + return e.Where("type=?", USER_TYPE_INDIVIDUAL).And("email=?", email).Get(new(User)) } // IsEmailUsed returns true if the email has been used. diff --git a/templates/.VERSION b/templates/.VERSION index e3ea0be9d..a6d787ee3 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.9.125.0128 \ No newline at end of file +0.9.126.0129 \ No newline at end of file