Using multiple authentification methods


I am currently building an AdonisJS app that consists of a dashboard and an API for my App. I am using the default AdonisJS authentification.

The dashboard should use the session method, but my API should use the JWT for authenticating users.

How do I do that? It seems like I need to set the method inside of config/auth.js and can’t just say "Use session by default, but JWT for all requests inside the route group /api/"

1 Like


To switch authentication method : Adonis doc - Auth Switch

For verification purposes : Adonis doc - Auth JWT check()


Using middleware auth:, closure).middleware(['auth:jwt'])

^ source

Have a nice day :grinning: