fix: require authenticated customer on stock alert frontend routes#18
Merged
S-Tian86 merged 1 commit intoJul 20, 2026
Merged
Conversation
The frontend routes were only hidden through the customer menu but never protected at the route level, so an anonymous visitor (or a crawler) hitting /stock-alert/ reached indexAction directly. There getUser() returns a CustomerVisitor, which has no getOrganization() nor getId(), raising a NoSuchPropertyException 500 instead of asking the user to log in. Guard the four frontend actions with IS_AUTHENTICATED_REMEMBERED, the same check Oro uses on its own "my account" pages, so anonymous visitors are redirected to login while remember-me sessions keep working. Since the user is now guaranteed to be a CustomerUser, drop the phpstan-ignore hints in indexAction.
Collaborator
Author
|
Sibling PR for the 7.0 line (master): #19 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The frontend
/stock-alert/*routes are only hidden through the customer account menu, but they are not protected at the route level. An anonymous visitor — or a crawler — hitting/stock-alert/reachesindexAction()directly.There,
getUser()returns aCustomerVisitor(from theAnonymousCustomerUserToken), which has nogetOrganization()norgetId(). The result is a 500:The
@phpstan-ignore-next-linehints already flagged that these accesses were not type-safe.What
Guard the four frontend actions (
form,indexAction,createAction,deleteAction) withdenyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED')— the same check Oro uses on its own "my account" pages (CustomerUserProfileController::profileAction). Anonymous visitors are now redirected to login, while remember-me sessions keep working (REMEMBERED, notFULLY).Since the user is then guaranteed to be a
CustomerUser, the@phpstan-ignore-next-linehints inindexActionare removed.Notes
Same fix is opened against
master(7.0 line) in a sibling PR.