Skip to content

fix: require authenticated customer on stock alert frontend routes#18

Merged
S-Tian86 merged 1 commit into
synolia:6.0from
S-Tian86:bugfix/stock-alert-anonymous-access
Jul 20, 2026
Merged

fix: require authenticated customer on stock alert frontend routes#18
S-Tian86 merged 1 commit into
synolia:6.0from
S-Tian86:bugfix/stock-alert-anonymous-access

Conversation

@S-Tian86

Copy link
Copy Markdown
Collaborator

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/ reaches indexAction() directly.

There, getUser() returns a CustomerVisitor (from the AnonymousCustomerUserToken), which has no getOrganization() nor getId(). The result is a 500:

NoSuchPropertyException: There is no "getOrganization" method in
"Oro\Bundle\CustomerBundle\Entity\CustomerVisitor" entity

The @phpstan-ignore-next-line hints already flagged that these accesses were not type-safe.

What

Guard the four frontend actions (form, indexAction, createAction, deleteAction) with denyAccessUnlessGranted('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, not FULLY).

Since the user is then guaranteed to be a CustomerUser, the @phpstan-ignore-next-line hints in indexAction are removed.

Notes

Same fix is opened against master (7.0 line) in a sibling PR.

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.
@S-Tian86

Copy link
Copy Markdown
Collaborator Author

Sibling PR for the 7.0 line (master): #19

@S-Tian86
S-Tian86 merged commit 863868f into synolia:6.0 Jul 20, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant