Skip to content

Commit bd55f6f

Browse files
authored
Detect noreply email address as user (#7133)
1 parent dadc03f commit bd55f6f

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
@@ -1334,6 +1334,19 @@ func GetUserByEmail(email string) (*User, error) {
13341334
return GetUserByID(emailAddress.UID)
13351335
}
13361336

1337+
// Finally, if email address is the protected email address:
1338+
if strings.HasSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress)) {
1339+
username := strings.TrimSuffix(email, fmt.Sprintf("@%s", setting.Service.NoReplyAddress))
1340+
user := &User{LowerName: username}
1341+
has, err := x.Get(user)
1342+
if err != nil {
1343+
return nil, err
1344+
}
1345+
if has {
1346+
return user, nil
1347+
}
1348+
}
1349+
13371350
return nil, ErrUserNotExist{0, email, 0}
13381351
}
13391352

0 commit comments

Comments
 (0)