Friday 15 May 2015

symfony2 - Symfony can't detect the roles from FOSUser -



symfony2 - Symfony can't detect the roles from FOSUser -

i setting user management website fosuser first time , i'm having problem figuring out mess up.

the role in database, in roles column, this:

a:1:{i:0;s:10:"role_admin";}

when var_dump($this->getuser()) controller, this:

(...) ["roles":protected]=> array(1) { [0]=> string(10) "role_admin" } (...)

so everything's fine on here too.

when seek either if ($this->get('security.context')->isgranted('role_admin')) controller or {% if is_granted('role_admin') %} twig template, symfony doesn't observe role. profiler tells me there role_user role.

here app/config/security.yml file:

security: providers: main: id: fos_user.user_provider.username encoders: site\userbundle\entity\user: sha512 role_hierarchy: role_moderator: [role_user] role_admin: [role_moderator] firewalls: main: pattern: ^/ anonymous: true form_login: login_path: fos_user_security_login check_path: fos_user_security_check logout: path: fos_user_security_logout target: / remember_me: key: %secret% default: anonymous: ~

it looks didn't clear cache. seek clear cache environment

php app/console cache:clear --env=prod #for prod env

or

php app/console cache:clear #for dev env

symfony2 fosuserbundle roles

No comments:

Post a Comment