How to write separate JWT and Session based routes?


#1

My Config/auth.js is

authenticator: 'jwt',
  session: {
    serializer: 'mongoose',
    model: 'App/Models/User',
    scheme: 'session',
    uid: 'email',
    password: 'password'
  },
jwt: {
    serializer: 'mongoose',
    model: 'App/Models/User',
    scheme: 'jwt',
    uid: 'email',
    password: 'password',
    options: {
      secret: Env.get('APP_KEY'),
      expiresIn: 1800 // 30 minutes
    }
  },

Route.js is

Route.group(() => { 
    Route.get('/admin/dashboard', 'AdminController.dashboard') 
}).middleware(['auth:session'])

Route.group(() => { 
    Route.get('/api/userDetails', 'ApiController.userDetails')
}).middleware(['auth:jwt'])