How to handle blocked/suspended user with JWT authentication


#1

Hi, everyone
I wonder how to inject jwt authentication with my rules
I have admin user who can block/suspend other user, so in users table I have a column named blocked which is a boolean
Currently I’m using jwt authentication like this https://adonisjs.com/docs/4.1/authentication#_auth_middleware

const namedMiddleware = {
  auth: 'Adonis/Middleware/Auth'
}
Route
  .get('users/profile', 'UserController.profile')
  .middleware(['auth'])

I want everytime I call auth (or may be myAuth) middleware, it checks if user is blocked and handle it with my code
Then, if the user is blocked, it will return 401

Thanks