This question may sound stupid but I still wanna know what else I can do to achieve this functionality.
There's an inventory system built as a REST API and there are two types of users.
users
admins
Let's say when an user logs in, he's given a JWT token that contain following information.
email
, user_id
, user_level
This token is decoded in each private route and checks if the user is authenticated and also checks the user level to make sure the user is authorized to access that particular resource.
Let's consider a special scenario that an admin (Admin A) logs in and start doing some admin stuff on the system. Suddenly another admin (SuperAdmin) wants to downgrade Admin A to a normal user for some reason. However, even-though now Admin A is just a normal user, his token is still an Admin token. So, he can still do admin stuff until the token automatically expires in one hour.
So, in a scenario like this what's the way to expire that token manually ? Does the system should use a DB query to check user level for each admin route ? Or is there any other way to achieve this ?
Hope you get this clearly.