1
votes

(sorry for my bad english)

I need to create different types of users, with specific configuration for every user. Note that I know the existence of PUGXMultiUserBundle and FOSUserBundle, but I want to know if really I need to use this bundles.

I need 3 types of users:

  • SuperAdmin: do login at backend and have access to all data with no restrictions. Will be only one, no more. Can create new 'Admin' and 'User' users.

  • Admin: do login at backend (same form as SuperAdmin) and have access to same data as SuperAdmin but filtered to data created and asigned to it. Can be many users with this type of user. Can create new 'User' users.

  • User: do login at frontend and have access to their own data. Can create their own account.

Really I need to use PUGXMultiUserBundle to manage this ? Really I need three type of users of just two ? SuperAdmin and Admin will share same interface and there will be only ONE SuperAdmin.

Thanks for your help!

1

1 Answers

1
votes

You can provide many roles in Symfony 2 by adding them in the security.yml. You can set the page where the user can go by using access_control.

access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }

Another way to restrict access is by using annotation and the @Security.

You can define your users roles in the security.yml with role_hierarchy.

role_hierarchy:
        ROLE_SUPER_ADMIN: [ROLE_ADMIN] 
        ROLE_ADMIN: ROLE_USER

Notice that Symfony 2 provides a default for an authenticated person, the ROLE_USER.

Another thing, using FosUserBundle will allow you to save time.