[V5] Argument of type 'string' is not assignable to parameter of type '"api"'.ts(2345) #1604
-
Hello there, I've a issue about that happens after "node ace invoke @adonisjs/auth" command. I got this error in "app/Middleware/Auth.ts" file's 27th line: This is the function that I've got error: protected async authenticate (auth: HttpContextContract['auth'], guards: string[]) {
for (let guard of guards) {
if (await auth.use(guard).check()) { //! Warning is appearing on the 'guard' variable on this line.
auth.defaultGuard = guard
return true
}
} And here it is my contracts/auth.ts interface ProvidersList {
user: {
implementation: LucidProviderContract<typeof User>,
config: LucidProviderConfig<typeof User>,
},
}
interface GuardsList {
api: {
implementation: OATGuardContract<'user', 'api'>,
config: OATGuardConfig<'user'>,
},
} Could you help me, please? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Seems weird. Can you share when did you installed the Anyways, I recommend replacing the contents of |
Beta Was this translation helpful? Give feedback.
Seems weird. Can you share when did you installed the
@adonisjs/auth
package. Coz the middleware is using an outdated template (which shouldn't be the case for a new app).Anyways, I recommend replacing the contents of
app/Middleware/Auth
with this file https://github.com/adonisjs/auth/blob/develop/templates/middleware/Auth.txt