Is it possible to have separated Auth for different models in Adonis Js?
I have two different table for admins and users and want to have separated Auth.
How can I setup this in adonis js ?
Is it possible to have separated Auth for different models in Adonis Js?
I have two different table for admins and users and want to have separated Auth.
How can I setup this in adonis js ?
You can create new guards or providers by register them inside the contracts/auth.ts file to inform the TypeScript static compiler.
https://docs.adonisjs.com/guides/auth/introduction#configuring-new-guardsproviders
Example:
.....
interface GuardsList {
.....
apiUsers: {
implementation: OATGuardContract<'user', 'apiUsers'>,
config: OATGuardConfig<'user'>,
}
.....
}
.....
You can configure multiple authentication by adding new auth in your
config/auth.ts
inguards
section.Example
config/auth.ts
:Switch authentication :