Search code examples
phpsymfonysecurityrunas

How to check if another user of me can access on this current page


In my app I want to check if another user of the app can access a specific route.

How to use the security compoment of Symfony to load the target user context and check the right as if the user call the URL ?

EDIT :

I known the documentation of Symfony2. But all oriented for current logged user. But in my case, I'm an admin and I want share the current page with another admin.

Before send the share email, I want check if the another admin can read the shared page.


Solution

  • My solution :

    1) create a token \Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken with user.

    2) use the 'security.access.decision_manager' for decide if the user have the granted access.

    This solution is simple but not shared here.