Auth guard "user_id" #1285
Answered
by
thetutlage
backspacerhino
asked this question in
Help
-
Hi, When I use const token = await auth.use('someguard').generate(account, {
expiresIn: '10 days',
}) I get error for my Is there a way for me to specify the foreign key name instead of default "user_id" |
Beta Was this translation helpful? Give feedback.
Answered by
thetutlage
Jul 21, 2020
Replies: 2 comments 3 replies
-
Any reasons for a using a different foreign key name? The |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
backspacerhino
-
In adonis v5, just change the settings in 'config/auth.ts' import Account from 'App/Models/Account'
import { AuthConfig } from '@ioc:Adonis/Addons/Auth'
const authConfig: AuthConfig = {
guard: 'api',
list: {
api: {
driver: 'oat',
tokenProvider: {
driver: 'database',
table: 'api_tokens',
},
provider: {
driver: 'lucid',
identifierKey: 'id',
uids: ['id'],
model: Account,
},
},
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any reasons for a using a different foreign key name? The
user_id
is required to know for which user the token is generated