adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
187 stars 65 forks source link

Executing `node ace configure @adonisjs/auth --guard=access_tokens` does not pass `tokens: 'authTokens'` to tokensUserProvider #232

Closed kaypee90 closed 6 months ago

kaypee90 commented 6 months ago

Package version

@adonisjs/auth@9.1.1

Describe the bug

As stated in the authentication documentation for Adonis version 6, this is the required structure for authConfig in the config/auth.ts file

const authConfig = defineConfig({
  default: 'api',
  guards: {
    api: tokensGuard({
      provider: tokensUserProvider({
        tokens: 'authTokens',
        model: () => import('#models/user'),
      })
    }),
  },
})

But executing the command configure command node ace configure @adonisjs/auth --guard=access_tokens the generated config/auth.ts file excludes tokens: 'authTokens', you rather get

const authConfig = defineConfig({
  default: 'api',
  guards: {
    api: tokensGuard({
      provider: tokensUserProvider({
        model: () => import('#models/user')
      }),
    }),
  },
})

This issue is related to https://github.com/adonisjs/core/discussions/4372

Reproduction repo

No response

thetutlage commented 6 months ago

Hello, this issue was fixed in this commit. https://github.com/adonisjs/presets/commit/b379c6bf3865040b60e49beca3f17ae63988c760

Maybe when you configured the guard, you were using an older version of @adonisjs/auth package.


Also, I have noticed that our stubs use the term accessTokens and docs use authTokens. I have update the docs to match the default stubs naming convention here. https://github.com/adonisjs/v6-docs/commit/b7e424abbd192c1f9c4751f6d72fca996d2be7b9