Multi model in jwt authentication


#1

Hey, is it possible to have more than one model in jwt authentication?

Currently i have this auth config:

{
  user: {
    serializer: 'lucid',
    model: 'App/Models/User',
    scheme: 'jwt',
    uid: 'cpf',
    password: 'password',
    options: {
      secret: Env.get('APP_KEY')
    }
  },
  admin: {
    serializer: 'lucid',
    model: 'App/Models/Admin',
    scheme: 'jwt',
    uid: 'cpf',
    password: 'password',
    options: {
      secret: Env.get('APP_KEY')
    }
  }
}

And i wanted that both users could use the same route using auth middleware, i tried:

.middleware('auth:user,auth:admin')
.middleware(['auth:user','auth:admin'])

But in controller auth always returns from the user table, even when using token from admin_tokens.

Is it possible or do i have to use different routes?

Thanks