multiple authorizations [v5] #1785
Unanswered
sasha172017
asked this question in
Help
Replies: 2 comments 2 replies
-
Just have a flag in the users table to represent whether it is a normal user or staff. 1 authentication, 1 table, 1 model :)
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I did it in v4.1 having several auths. const authenticator = auth.authenticator('jwt_user')
result = await authenticator
.query(extraConditions)
.attempt(data.email, data.password, true) Then, in config, you must add: jwt_user: {
serializer: 'lucid',
model: 'App/Models/User',
scheme: 'jwt',
uid: 'email',
password: 'password',
options: {
secret: Env.get('APP_KEY'),
audience: 'user'
}
},
jwt_staff: {
serializer: 'lucid',
model: 'App/Models/Staff',
scheme: 'jwt',
uid: 'email',
password: 'password',
options: {
secret: Env.get('APP_KEY'),
audience: 'staff'
}
}, So in v5 should be similar. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Can i`ll make multiple auth in adonis? i need tables user, staff and models user, staff and for them should be own registration and auth. Can i later receive user and staff like this - ctx.auth.user, ctx.auth.staff. And actually i want than make one model api_tokens for this auth. How can i do it? thank you=)
Beta Was this translation helpful? Give feedback.
All reactions