Silex/Symfony Security Firewall Access user token outside the secured area

十年热恋 提交于 2019-12-02 10:10:10

But then what you need to do, is put that page under the firewall too. Change the firewall setting so / is the firewall, and add ACL so anonymous can also enter to /. Then you can have there user data.

Where you load in your header data, you check that the user is authenticated or not, cause this is the main thing, isGranted('IS_AUTHENTICATED_REMEMBERED') and depending on the result, you will include different template file.

The user information is only available in secured areas, to get access also outside of these areas you must allow anonymous users as described in the documentation:

$app['security.firewalls'] = array(
'unsecured' => array(
    'anonymous' => true,

    // ...
),
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!