Reputation: 651
Whene displayin the app.user object like this in Twig
{{ dump(app.user) }}
I got all information about the current user
How can I configure Symfony for storing only the username for example in the Session. Thanks
Upvotes: 0
Views: 1837
Reputation: 48865
You can plugin your own UserInterface class (perhaps by overriding the existing Symfony class and then adjust the eraseCredientials() method to null out the password and the salt if you want. http://symfony.com/doc/current/reference/configuration/security.html
You can even go further and add __sleep and __wakeup methods (http://php.net/manual/en/language.oop5.magic.php#object.sleep) to control exactly which member variables end up in the session.
Upvotes: 1
Reputation: 5881
app.user
returns what is stored in the security token to identify your user. Probably, you will not want to change that. However, you can, for example, create a custom Twig function which only returns the username if you want to have an easier way to access that value.
Upvotes: 2