symfony - Symfony2 FosUserBundle Roles ROLE_ADMIN -


I have found this problem.

My SF2NView is configured with FusiusBandal and FacebookBundle.

I have succeeded in section only on some ADMIIN FRONTAGE (means mediator object) By default, every user created in my project is only ROLE_USER.

The "moderator" thing can only be accessed by being ROLE_ADMIN The problem is that I "" $ user-> Also add the role of addRole ('ROLE_ADMIN') , checking that the user's role is unsuccessful. I would like to show some stuff if the user has the role to play, but I can not.

Neither " {% if_granted ('ROLE_ADMIN')%} ", nor " $ this-> container->; ('security.context ') -> (' ROLE_ADMIN ') isGranted "succedded"

Everybody is not getting anything wrong or when it comes to twig .

Check if the user has ROLE_USER works

Just to make sure I'm adding my config content.

  Security: Ankoders: FOS \ UserBundle \ Model \ UserInterface: sha512 Symfony \ Component \ Security \ Core \ User \ User: plain text Bhumika_hriday: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: ROLE_ADMIN providers Chen_proveedr: Chen : Provider: [fos_userbundle, my_fos_facebook_provider] fos_userbundle: id: user_provider my_fos_facebook_provider: id: my.facebook.user firewalls: public: Pattern: ^ / form_login: login_path: / login chuck k_path: / login_check Provider: fos_userbundle csrf_provider: form.csrf_provider use_referer true fos_facebook: APP_URL: "http://www.facebook.com/apps/application.php?id={{APPID}}" SERVER_URL: "http: / /l.local/app_dev.php/" login_path: / Login check_path: / login_fb_check default_target_path: / Provider: My_fos_facebook_provider Use_referer truth logout: Path: / logout invalidate_session: false anonymous truth access_control: - {path: ^ / login $ role: IS_AUTHENTICATED_ANONYMOUSLY} - {path: ^ / register, role: IS_AUTHENTICATED_ANONYMOUSLY} - {path: ^ / Reset, role: IS_AUTHENTICATED_ANONYMOUSLY} - {path: ^ / admin /, role: ROLE_ADMIN} - {path: ^ / safe /. * Role: IS_AUTHENTICATED_FULLY} - {path: ^ / Facebook / role: [ROLE_FACEBOOK]} - {path: ^ / Dodaj $ role: ROLE_USER} - {path :. ^ / * Role: [IS_AUTHENTICATED_ANONYMOUSLY]}   

Please, if anyone can help, I do not know what I have to do

I always make Checking to see if my role ("ROLE_ADMIN") has been added to my database, and in fact, it is.

The role is the process on session generation (connection, login ...). If you security context (can be obtained from the session) directly into a branch template or elsewhere securityContext object:

Twig template is_granted ( 'ROLE_ADMIN') < / p>

In the Controller (with security reference) $ securityContext-> Use iGreand ('ROLE_ADMIN')

Do not forget to re-sign after the roll change.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -