1

I'm trying to learn symfony by creating a simple project. I began by creatin a dashboard for the admin.

This administrator have the right to create a type of users called "Proprietaire", once this "proprieraire" is connected he can create another type of users "Simple user".

I tried to manage login for admin using FOSUserBundle and i get it done.

The problem now is how to create "proprietaire" type user using a form from the admin page? and how to do the same for creating "simple" type user from "proprietaire" page ?

I have three roles : ROLE_ADMIN, ROLE_PROP and ROLE_SIMPLE

my security.yml file :

# app/config/security.yml

security: encoders: FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
    ROLE_PROP:       ROLE_USER
    ROLE_ADMIN: ROLE_PROP

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
            # if you are using Symfony < 2.8, use the following config instead:
            # csrf_provider: form.csrf_provider

        logout:       true
        anonymous:    true

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/safeparking/admin, role: ROLE_ADMIN }
    - { path: ^/safeparking, role: IS_AUTHENTICATED_ANONYMOUSLY }

I'm using Symfon 2.8.5 so PUGXMultiUserBundle isn't a solution for me.

Habchi
  • 1,921
  • 2
  • 22
  • 50
  • very similar question to the one I answered in [this question](http://stackoverflow.com/questions/37046048/symfony-fosuserbundle-3-different-profiles-depending-on-role/37046226#37046226). If you have any questions comment here, not there. – DevDonkey May 09 '16 at 08:13
  • I'm really sorry but i can't figure out how can i implement this, i don't know what's the AbstractType is and the real problem for me is how to make FOSUserBundle manage the creation of my three different users using another route than the /register that he give by default. Feel free to ask questions so that i can give you more details. Thanks in advance – Habchi May 09 '16 at 08:54

0 Answers0