H
H
HellWalk2019-11-08 10:57:24
symfony
HellWalk, 2019-11-08 10:57:24

How to check if a user is NOT authorized in Symfony?

All examples describe cases when you need to check for some access rights to the page (via Voter), but I need the opposite - so that only unauthorized users have access to the page.
You can, of course, check for ROLE_USER (if there is, do a redirect from the page), which, as it were, all users have. But what if a user without this role somehow appears later?
It's better to just check if the user is logged in or not. But how to do it (in the controller)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2019-11-08
@HellWalk

https://symfony.com/doc/current/security.html#chec...
!$this->isGranted('IS_AUTHENTICATED_REMEMBERED');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question