lingthio / Flask-User

Customizable User Authorization & User Management: Register, Confirm, Login, Change username/password, Forgot password and more.
http://flask-user.readthedocs.io/
MIT License
1.06k stars 294 forks source link

Multiple user models #162

Open NikolaJankovic opened 7 years ago

NikolaJankovic commented 7 years ago

From the documentation it seems as if flask-user only works with a single User model (only one declared when initializing SQLAlchemyAdapter.) That works fine for a single standard type of user but my current schema requires multiple user models each with very different columns; 'users' is just a basic user model while 'clients' require very different data.

Is there a possible workaround for this problem? The only one I can think of is to combine the two models but that would be incredibly disorganized and just a mess.

Does flask-user allow initializing with multiple user models or some solution to this problem?

RylanC24 commented 7 years ago

I am running into the same issue right now. I have two types of users that are very different. One user class is already implemented with flask-user and uses the features heavily. The second user class only needs user authentication and remember_token (essentially just the functionality of flask-login). However, since flask-user is build on top of flask-login the user_manager 'hogs' the login_manager and prevents me from creating a new one to handle the second user class.

It's also worth mentioning that the first user class is already in use so making changes to this model and the associated db table would be kind of a pain. Though if I don't find any alternatives this might be what I'm stuck with.

Does anyone have any suggestions on how I can rectify this situation?

dumptyd commented 7 years ago

I'm running into the same issue. Did you guys find a workaround for this?

RylanC24 commented 7 years ago

I could not find a work around for this problem. I ended up having to implement my own session management system for one of the types of users (the type that did not have to be quite as secure).

lingthio commented 7 years ago

I don't see an easy way for Flask-User to support this use-case. If you think of an elegant solution, send me a pseudo code example, and I will re-consider.

d-Narwani commented 4 years ago

Could anyone find a solution for this?