Using multiple authentification methods

Hello,

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

Hi,

To switch authentication method : Adonis doc - Auth Switch

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

OR

Using middleware auth:

Route.post(url, closure).middleware(['auth:jwt'])

^ source

Have a nice day :grinning:

3 Likes