Let's say I have my access_controlblock under security.yml:
access_control:
- { path: ^/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/reset-password, roles: IS_AUTHENTICATED_ANONYMOUSLY }
In this case, everyone can enter the pages homepageand reset-password. But I would like to allow these pages only for users anonymously anonymous. Fully Authenticated Users Must Receive 403 access denied errorOr 404 page not found.
According to the documentation with allow_ifI should be ablo to create role expressions to define access. But if I do it like this:
access_control:
- { path: ^/reset-password, allow_if: "has_role('IS_AUTHENTICATED_ANONYMOUSLY') and not has_role('IS_AUTHENTICATED_FULLY')" }
Now, following the idea, fully authorized users (login) should not have access to the page, and anonymous authentication should have access, but, unfortunately, none of the users can access it ...
Any ideas what I am missing?
UPDATE
This made it work, as suggested below, with the correct answer:
- { path: ^/reset-password, allow_if: "is_anonymous() and !is_authenticated()" }
source
share