diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-02-21 22:20:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 22:20:34 +0800 |
commit | dc988eae0c5a81b1228677667c7c940905626110 (patch) | |
tree | d9fc76490816cc7df800dde3519cdae312eddd6e | |
parent | 54dd0fc88bdef7e9ab92003a9cc79c41423899e6 (diff) | |
download | gitea-dc988eae0c5a81b1228677667c7c940905626110.tar.gz gitea-dc988eae0c5a81b1228677667c7c940905626110.zip |
Fix bug for get user by email (#18833)
Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r-- | models/user/user.go | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/models/user/user.go b/models/user/user.go index bd55249448..b61ffd7072 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1117,19 +1117,9 @@ func GetUserByEmailContext(ctx context.Context, email string) (*User, error) { } email = strings.ToLower(email) - // First try to find the user by primary email - user := &User{Email: email} - has, err := db.GetEngine(ctx).Get(user) - if err != nil { - return nil, err - } - if has { - return user, nil - } - // Otherwise, check in alternative list for activated email addresses - emailAddress := &EmailAddress{Email: email, IsActivated: true} - has, err = db.GetEngine(ctx).Get(emailAddress) + emailAddress := &EmailAddress{LowerEmail: email, IsActivated: true} + has, err := db.GetEngine(ctx).Get(emailAddress) if err != nil { return nil, err } |