symfony - Roles in login not being stored in User of security context -


I did not find the answer after searching for 2 days and trying many different solutions. I have followed the steps of a tutorial () to create a simple login process, where I have:

  • Table for the user
  • The table for the role < / Li>

Many links between them (user_rol) all mysql tables were created correctly and I also have ORM theory classes

If I hand a user Loads from and loads their roles so it works perfectly well But when I use the automatic login

  {% block body%} {% error%} & Lt; Div & gt; {{Error.message}} & lt; / Div & gt; {% Endif%} & lt; Form action = "{{path ('login_check')}}" method = "post" & gt; & Lt; Label = "username" & gt; Use: & lt; / Label & gt; & Lt; Input id = "user name" type = "text" name = "_username" value = "{{last_username}}" /> & Lt; Label = "password" & gt; Contribution: & lt; / Label & gt; & Lt; Input id = "password" type = "password" name = "_ password" /> {# If you want to control the URL then the user has been redirected to success (more details below) & lt; Input type = "hidden" name = "_ target_path" value = "/ account" /> #} & Lt; Input type = "submit" name = "login" /> & Lt; / Form & gt; {% Endblock%}  

The user is identified after logging in but the _profiler has a warning message that is "not authentic" (perhaps because a user's role Is not)

So I do this in code:

  $ user = $ this-> Get ('security.context') - & gt; GetToken () - & gt; GetUser (); Print_r (count ($ user- & gt; getRoles ()))  

And any roles are empty?

PD: I tried overwriting the object's serialization function and included roles but it does not work.

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -