Skip to content

Commit

Permalink
Detect noreply email address as user (#7133) (#7195)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath authored and techknowlogick committed Jun 13, 2019
1 parent 10effb3 commit 76e8eec
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,19 @@ func GetUserByEmail(email string) (*User, error) {
return GetUserByID(emailAddress.UID)
}

// 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)
if err != nil {
return nil, err
}
if has {
return user, nil
}
}

return nil, ErrUserNotExist{0, email, 0}
}

Expand Down

0 comments on commit 76e8eec

Please sign in to comment.