Closed rodrigorz closed 3 years ago
@adonisjs/ace: ^6.0.0 @adonisjs/auth: ^4.3.1 @adonisjs/core: ^5.0.0-preview-rc @adonisjs/fold: ^6.0.0 @adonisjs/lucid: ^8.4.4
Node: v12.18.3 npm: 6.14.6
My config/auth.ts
config/auth.ts
apiPlayer: { driver: 'oat', tokenProvider: { driver: 'database', table: 'player_tokens', }, provider: { driver: 'lucid', identifierKey: 'id', uids: ['email'], model: Player, }, },
My contracts/auth.ts
contracts/auth.ts
interface ProvidersList { player: { implementation: LucidProviderContract<typeof Player>, config: LucidProviderConfig<typeof Player>, }, } interface GuardsList { apiPlayer: { implementation: OATGuardContract<'player', 'apiPlayer'>, config: OATGuardConfig<'player'>, }, }
When a try to await auth.use('apiPlayer').attempt(email, password) i get this error:
await auth.use('apiPlayer').attempt(email, password)
insert into `player_tokens` (`created_at`, `expires_at`, `name`, `token`, `type`, `user_id`) values ('2020-10-10 14:15:27', NULL, 'Opaque Access Token', 'aa72d4c672f7d55f812dc4fd4c4bd68b0c018c4517e1c2257b4f86c6e2b84ad4', 'opaque_token', 1) - ER_BAD_FIELD_ERROR: Unknown column 'user_id' in 'field list'
I think all i need to do is use player_id instead of user_id, because the player_tokens table has a column player_id to reference players table.
player_id
user_id
player_tokens
players
How can i do that?
An existing PR already fixes this issue https://github.com/adonisjs/auth/pull/152. It will be released soon
Package version
@adonisjs/ace: ^6.0.0 @adonisjs/auth: ^4.3.1 @adonisjs/core: ^5.0.0-preview-rc @adonisjs/fold: ^6.0.0 @adonisjs/lucid: ^8.4.4
Node.js and npm version
Node: v12.18.3 npm: 6.14.6
Sample Code (to reproduce the issue)
My
config/auth.ts
My
contracts/auth.ts
When a try to
await auth.use('apiPlayer').attempt(email, password)
i get this error:I think all i need to do is use
player_id
instead ofuser_id
, because theplayer_tokens
table has a columnplayer_id
to referenceplayers
table.How can i do that?