Answer the question
In order to leave comments, you need to log in
Is it possible to split authentication in Yii2 basic template?
I am building a website that will provide for work with a client base - a user profile, a personal account, etc.
Accordingly, there will be an admin panel, which will be used by a group of people - admin, managers, operators, etc.
I would not want to store all these accounts in one users table, separation is clearly needed here. For example, users for the site administration group and clients for clients.
As far as I understand, the yii\web\User class is responsible for authentication in yii2, and it is common in the yii2-basic template. Those. if the admin's id from the users table is 1, and the client's id from the clients table is also 1, then they will overlap each other.
Do I understand the scheme of work correctly and is it possible to separate authentication without transferring the project to an advanced template? Maybe the question is lamer, then it’s not even finished yet)
Answer the question
In order to leave comments, you need to log in
Take the ready-made module https://github.com/dektrium/yii2-rbac
With it, the database will already be perfectly divided, there will be 4 tables with rights, with roles and profile (here personal data is stored)
Only the login and accesses will be stored in the native table
I would not want to store all these accounts in one users table, there is clearly a need for separation
Alternatively, you can do this in the config:
'components' => [
...
'userAdmin' => [
'identityClass' => 'common\models\UserAdmin',
],
'userClient' => [
'identityClass' => 'common\models\UserClient',
],
...
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question