Search code examples
symfonysecurityeventssymfony4

Symfony 4 First Event


I authenticate the user with ROLE_USER after that user open another URL need ROLE_ADMIN i want to add this role if the user has the role in the database. I'm going to use an event listener but I get access denied before kernel.request event execute.


Solution

  • I used kernel.exception event when the statusCode was 403 (Access Denied) set the ROLE_ADMIN