Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two or more identityClass models #5134

Closed
usualdesigner opened this issue Sep 22, 2014 · 9 comments
Closed

Two or more identityClass models #5134

usualdesigner opened this issue Sep 22, 2014 · 9 comments

Comments

@usualdesigner
Copy link
Contributor

Is there way to use two or more identityClass for sign-in? I have three very different models (User, Manager, Member) and can I use all of these models as identityClass?

@qiangxue
Copy link
Member

Nope, only a single identity class is supported. You should consider extending your different model classes from the common base identity class.

@usualdesigner
Copy link
Contributor Author

Is it a good idea to extend base User Model and use three table for each model and mysql view for base User model? What is your view?

Each of these models has too many different fields and i would not want to store all different data in one table. My idea is create mysql view table with base fields (username, password_hash etc.).

Or it's have no sense and store all data in one table is good solution?

@qiangxue
Copy link
Member

It's totally fine that you have different kinds of user models which are stored in different tables or databases. However, if you want to support authentication using all these models, you should provide some common interface for them and have a way to differentiate them (e.g. introducing a user type).

You may implement an identity class which creates different user models based on the given type information.

@usualdesigner
Copy link
Contributor Author

Thanks

@KishanT
Copy link

KishanT commented Jul 10, 2015

can you provide more information on this? I am facing the same issue.

@comiguel
Copy link

@usualdesigner help me please!, how you resolved finally this problem? what's better option?
Thanks in advance

@fcaldarelli
Copy link
Member

As suggested, you should have a class user and then three classes one for each kind of user, related to user class with a user_Id field, for example

@daskon
Copy link

daskon commented Dec 9, 2015

Please give me the code solution for this issue. I have a Assignment to do. my DB has two tables, one for Tutor another one for users. users table is used to login to the system as student. and same goes for Tutor table. up to now students can login. but can't login Tutor. when I'm entering Tutor login details it goes to users login. this Assignment is kind of Student feedback portal. using Yii2.
( can i do something with 'switchIdentity()' or loginByCookie() )
PLEASE HELP ME GENTLEMEN-TS !!

@SilverFire
Copy link
Member

@daskon please use forum for questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants