Detect noreply email address as user (#7133) (#7195)

This commit is contained in:
zeripath 2019-06-13 17:16:50 +01:00 committed by techknowlogick
parent 10effb396a
commit 76e8eec3d9
1 changed files with 13 additions and 0 deletions

View File

@ -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}
}