Use ID or Where to instead directly use Get when load object from database (#11925) (#11935)

Backport #11925

Use ID or Where to instead directly use Get when load object from database

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2020-06-17 21:54:26 +02:00 committed by GitHub
parent 313ace93d0
commit dbe9c11238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 29 deletions

View file

@ -1457,8 +1457,8 @@ func GetUserByEmail(email string) (*User, error) {
// Finally, if email address is the protected email address:
if strings.HasSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress)) {
username := strings.TrimSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress))
user := &User{LowerName: username}
has, err := x.Get(user)
user := &User{}
has, err := x.Where("lower_name=?", username).Get(user)
if err != nil {
return nil, err
}