DEV Community

Lucky Gautam
Lucky Gautam

Posted on

How to handle different type of user account in flask

If i use 2 user_login and 2 user_loader method then i able to access another account and vice versa. So to manipulate login page of Both Account Like :- Student and Member so that students shouldn't be access Member Account. If anyone knows help me .I've Searched it bunch of website but i didn't get it.

Top comments (1)

Collapse
 
chiragpandya7 profile image
Chirag Pandya • Edited

The way I handled it was to have a column in your users database. (Either a boolean column like "isMember", or if you want multiple user classes then a column with level of access for each user). And then in login code, check which level of access the user has and redirect him accordingly. This works for relatively simple setup.
But if you're looking for something more complicated then you can lookup Flask-Principal module. pythonhosted.org/Flask-Principal/
Hope it helps!!