Search code examples
vue.jsflaskflask-restfulflask-jwt-extended

Using flask_restful with flask _jwt for multiple users


I have a project i have to use flask_restful for multiple users using flask_jwt_extended. How do i implement it for 3 types of authentication ? i have one members(users) , one for creator and the last one for admin. how do i do so? i have created models.py, resource. py can anyone guide me accordingly

i tried a lot of videos, but none of them were helpful reguarding the same but most of them want to use blue prints in flask also most of them don't use multiple login criteria i have to use this at backend with vue.js 3 at front end i am lot confused


Solution

    • you can add a column named "role" in your db user table
    • now every user can be (member-creator-admin) by default the user role is member
    • make a condition when the user sign-in with his mail (if this mail has a role = ... redirect to this url)
    • on every fct in your code check for user permission before start your function (you can do this by creating a global fct named check_user_role() for example)