diff options
author | Lunny Xiao | 2022-02-22 02:34:22 +0800 |
---|---|---|
committer | GitHub | 2022-02-21 18:34:22 +0000 |
commit | 86c3481effd5a5e7e9d486577df993f1b4f1adc3 (patch) | |
tree | 8abe82f1a35846dcfed26d4bfaaed99998adfeb7 | |
parent | 039eb66c8c20230a326f955dc62637ed44d2802e (diff) |
Fix bug for get user by email (#18834)
Backport #18833
Fix #18830
-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 57a7fcadf..1508b2420 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1104,19 +1104,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 } |