Reputation: 371
My user provider is set to User entity.
The entity has getRoles() model and it works properly.
My problem is that:
How do I do so that that database changes apply to the session, without having to log out?
Upvotes: 0
Views: 155
Reputation: 371
I went with Symfony's voters: https://symfony.com/doc/current/security/voters.html
Could not be able to achieve it without Security Roles without logging-out.
Upvotes: 0
Reputation: 11
I think this question is similar to yours. The accepted answer was:
$user = $this->getUser();
$user->addRole('ROLE_ADMIN');
$this->get('fos_user.user_manager')->updateUser($user);
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.context')->setToken($token);
Upvotes: 1