0
votes

I am using the fos user bundle and I want to add two roles role_admin and role_user.

Should I do this in the securitiy.yml ?

role_hierarchy:
        ROLE_ADMIN:       ROLE_USER

The second question is that I don't have a column for role in my User table in the database. So how can roles be handled or should I add a column role to my table? More precisely : If I don't add an attribute to the entity User indicating the role, how could we know it?

1

1 Answers

0
votes

Yes, if you want to add some roles for your user, you have to do it into security.yml

However, if you correctly extended FOSUserBundle (by creating a User entity that extends FOSUserBundle baseUser class) you should have that column into your db schema.

Moreover, remember that FOSUserBundle provides CLI facilities for add role to a particular user, once you've created the user you want to use, and when you've created role into security.yml file