I am storing userid in token, i am authenticating the token and then after getting user id validating the user is enabled or not in mysql db. So for other tables i need userid for db queries as well, so how can i get user id in those functions? is there a way to get payload and fetch the the identity. Main.py
app.secret_key = "temp"
api = Api(app)
jwt = JWT(app,authenticate, identity) #/auth automatically
Security.py
def authenticate(username, password):
user = User.find_by_username(username)
if user and user.password == password:
return user
def identity(payload):
user_id = payload["identity"]
return User.find_by_userid(user_id)
User file
def find_by_userid(cls,_id):
#db connection
query = "select uid from users where uid= %s"
message file
#i want user id in this function as well
def fetch_msg_(cls,uid):