-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?

4
  • 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? ... Commented Sep 23, 2019 at 10:53
  • What means each one of user is linked by his own page? Commented Sep 23, 2019 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. Commented Sep 23, 2019 at 13:25
  • Does this answer your question? Symfony / Doctrine - Multiple Users Types Commented Jun 1, 2020 at 13:56

1 Answer 1

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...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.