diff options
author | zeripath <art27@cantab.net> | 2019-06-06 06:54:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-06 06:54:25 +0100 |
commit | bd55f6ff36d40503bfa3407225780d0ab7d37930 (patch) | |
tree | ca85b4b91e71600cbebf48080cdbb30fa8c7e8c7 /models | |
parent | dadc03f5ff07b0aa857ceccaa655bb4fb6e41494 (diff) | |
download | gitea-bd55f6ff36d40503bfa3407225780d0ab7d37930.tar.gz gitea-bd55f6ff36d40503bfa3407225780d0ab7d37930.zip |
Detect noreply email address as user (#7133)
Diffstat (limited to 'models')
-rw-r--r-- | models/user.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go index 9ee27ddfbd..e29cf5b32a 100644 --- a/models/user.go +++ b/models/user.go @@ -1334,6 +1334,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} } |