Answer the question
In order to leave comments, you need to log in
How to create 2 types of users in YIi2?
There are clients, there are partners.
Clients have certain fields in the database, while partners have others.
The bottom line is to have 2 tables of users and if a user from 'Clients' is authorized, then Yii2 does not recognize him as authorized in the module ('partners'). Well, vice versa. Is this even possible? (I understand that there is an option to create a user table, with fields: email, pass, user_type - then create other tables and output depending on the type of user, but this is not about that).
Answer the question
In order to leave comments, you need to log in
Clients are not always users of the system.
Partners are not always users of the system.
If you think in this way, then you need to share these responsibilities. It will be more correct. You will get a system divided into modules. This will allow you to make independence both at the code level and at the base level. Divide your code and base by responsibility.
src/Model/User
src/Model/СRM
You can assign roles to different types of users and set the rights to certain actions in the controller. This is done using RBAC as mentioned above. It is easy to google, but it may not be clear the first time, because there are many connections between each other. The idea is this: when a user registers, he is assigned a role. This role has a permission associated with it (there may be more than one.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question