adonisjs / v6-docs

Documentation website for AdonisJS v6
38 stars 53 forks source link

guardFactory is not a function #99

Closed tqvthu-works closed 1 month ago

tqvthu-works commented 2 months ago

Package version

^6.8.0

Describe the bug

I encountered an issue while configuring authentication guards in my AdonisJS application. I have defined the authConfig object in my config/auth.ts file as follows: config/auth.ts const authConfig = defineConfig({ default: 'api', guards: { api: tokensGuard({ provider: tokensUserProvider({ tokens: 'accessTokens', model: () => import('#models/user') }), }), }, })

In the start/routes.ts file, I'm trying to authenticate using the api guard as follows:

router.post('projects', async ({ auth, response }) => { // Authenticate using the default guard const user = await auth.authenticateUsing('api' as any); // from your docs // const user = await auth.authenticate() return response.send({ message: 'Project created', user: user }) })

The errors: image The issue is here (red section) image

Reproduction repo

No response

tqvthu-works commented 2 months ago

image Please correct your document! The argument must have an array instead of string!