Skip to content

Commit 76e8eec

Browse files
zeripathtechknowlogick
authored andcommitted
Detect noreply email address as user (#7133) (#7195)
1 parent 10effb3 commit 76e8eec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

models/user.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,19 @@ func GetUserByEmail(email string) (*User, error) {
13461346
return GetUserByID(emailAddress.UID)
13471347
}
13481348

1349+
// Finally, if email address is the protected email address:
1350+
if strings.HasSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress)) {
1351+
username := strings.TrimSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress))
1352+
user := &User{LowerName: username}
1353+
has, err := x.Get(user)
1354+
if err != nil {
1355+
return nil, err
1356+
}
1357+
if has {
1358+
return user, nil
1359+
}
1360+
}
1361+
13491362
return nil, ErrUserNotExist{0, email, 0}
13501363
}
13511364

0 commit comments

Comments
 (0)