Answer the question
In order to leave comments, you need to log in
Why don't groups work in FOSUserBundle?
Good evening,
Created a model of users and groups, connected them. To the user, gave him the admin group.
After that, he gave the group the role ROLE_CMS.
If the user calls getRoles(), then this role is present.
However, methods like isGranted(), i.e. those that are called from security.context for some reason do not find the role specified in the group.
What have I done wrong?
Let me explain with the controller code:
$this->getUser()->getRoles(); // array('ROLE_CMS', 'ROLE_USER');
$this->get('security.context')->isGranted('ROLE_CMS'); // false
$this->get('security.context')->isGranted('ROLE_USER'); // true
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question