-1

I am creating an application that should have at least 3 types of users. All of them have the same login form, and different registration forms.

Each user is linked by his own page.

So now I want to know the best and the simplest way to implement thisrequirements using Symfony 4?

Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49
  • 1
    How about some more details? The "best" way means what? Easy to implement? Easy to use? Easy to maintain? Easy to expand? What exactly are you implementing? Login? Registration? ... – Miro Lehtonen Sep 23 '19 at 10:53
  • What means each one of user is linked by his own page? – Frank B Sep 23 '19 at 12:36
  • I will need to manage several types of users in my projects, ie customers, administrators and drivers. By this I mean that each "entity" will have its own fields and will access a different part of the application. – Hamza Rouissi Sep 23 '19 at 13:25
  • Does this answer your question? [Symfony / Doctrine - Multiple Users Types](https://stackoverflow.com/questions/53286674/symfony-doctrine-multiple-users-types) – Az.Youness Jun 01 '20 at 13:56

1 Answers1

0

t is very easy to create multiple registration forms, so simple that it does not need any explanation i guess. At the end it is just a form that creates a new record in the User table...

Then you would like one login form. Fine because you can give users certain different roles. The only question remaining is that you maybe want to direct different users to a different page when they are successfully logged in. This is very easy too. Read the docs about generating a login form. At step drie you are able to redirect the user after login.

My advise would be to keep one User entity with sometimes some properties and methods that are not needed for every type of user. Use ROLES to separate different type of users, especially when you want to secure pages for some type of users.

Also read about Hierarchical Roles so that you know how to setup different roles like this little example here:

role_hierarchy:
    ROLE_DRIVER:         ROLE_USER  # normal driver
    ROLE_CUSTOMER:       ROLE_USER  # normal customer
    ROLE_ADMINISTRATOR:  ROLE_USER  # normal administrator
    ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ALLOWED_TO_SWITCH]  # this role is for you

One more thing you may ask yourself: What if a customer is also a driver or administrator...

Frank B
  • 3,667
  • 1
  • 16
  • 22