-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad loginAs method args type when chained to a guard #200
Comments
Can you share the |
Here is the file: import User from 'App/Models/User'
declare module '@ioc:Adonis/Addons/Auth' {
interface ProvidersList {
user: {
implementation: LucidProviderContract<typeof User>
config: LucidProviderConfig<typeof User>
}
}
interface GuardsList {
api: {
implementation: OATGuardContract<'user', 'api'>
config: OATGuardConfig<'user'>
}
}
} |
Its a bug with the default auth contract template. Lemme push a fix |
No problem, thank you for your reactivity. |
Any hint what the problem is? |
You will have to make the changes made in this commit manually. 946e730 The changes will be inside the |
@Foohx was guard or loginAs undefined for you when you run the tests? |
Don't remember but it was fixed by updating manually the auth contract. |
@Foohx got it, I fixed the type issue—I also had to use the |
@MANTENN Weird that you have to use the I'm using it without problem like this: const user = await UserFactory.apply('verified').with('roles').create()
const mock = sinon.mock(ConversationPolicy.prototype)
mock.expects('before').once().resolves(undefined)
mock.expects('viewList').once().resolves(true)
await client.get('/conversations').guard('api').loginAs(user).json({})
mock.verify()
mock.restore() But I am not in the latest version for the moment. I'm going to update all deps in the next few days and I'll let you know if I encounter the same problem. :) |
@Foohx I used the User.find(1) which either returns a user or null hence why I had to use the |
Okay, so everything is normal. |
In tests, only when chaining
loginAs
toguard
methods, arguments ofloginAs
method are of type never.Package version
@adonisjs/auth:
8.2.1
Node.js and npm version
Node.js:
16.13.0
npm:
8.10.0
Sample Code (to reproduce the issue)
Just create a new project with at least
@adonisjs/auth
package, then fill the existing test with the following code :The text was updated successfully, but these errors were encountered: