Skip to content

Commit

Permalink
Fix bug for get user by email (go-gitea#18833)
Browse files Browse the repository at this point in the history
Co-authored-by: zeripath <[email protected]>
  • Loading branch information
lunny and zeripath authored Feb 21, 2022
1 parent 54dd0fc commit dc988ea
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit dc988ea

Please sign in to comment.