-
Notifications
You must be signed in to change notification settings - Fork 112
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
Call resolve on error #18
Comments
Maybe something like this:
When I do this I get a 500 error, that make much more sense... |
Please, provide a repository which reproduces your issue. |
Simply follow this tutorial https://docs.nestjs.com/techniques/authentication step by step :-D |
but actually, you can also try there https://github.com/apiel/wudo You will get the response [1234] when you should not be authorize |
I think the problem is that when you put an unknown strategy into AuthGuard (e.g. |
I just pulled your repo and everything works well. I'm getting 401 when the token is not passed through the network, same as expected. |
Yes because in the mid-time, I have been working on it... As @DEX3 described, change @UseGuards(AuthGuard('bearer'))) to @UseGuards(AuthGuard('whatever'))) you will then get no error and have access to the entry point. Also, can you explain me why you are resolving error? Shouldn't error be rejected in a promise? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Parameters
|
The responsibility for checking whether a strategy exists belongs to passport library (that's why we cannot detect it earlier).
Because the resolved value is eventually passed to the Line 62 in e9d1766
|
If I remember correctly, resolve(new error...) is called before handleRequest and handleRequest is not called. You should really try to replace @UseGuards(AuthGuard('bearer'))) to @UseGuards(AuthGuard('whatever'))) , you will understand. |
You're absolutely right! Thank you for pointing me at this issue :) Fixed in 5.0.2 |
Close it ;) |
Hi. Was this really fixed? I have followed the guide and got the same error, I am using Nest 5.8.0. |
passport/lib/auth.guard.ts
Line 86 in e9d1766
https://github.com/jaredhanson/passport/blob/2327a36e7c005ccc7134ad157b2f258b57aa0912/lib/middleware/authenticate.js#L186
Here authenticate call "next" to trigger an error, but we provide "resolve" as "next" parameter. Shouldn't error call reject?
At least for me it's an issue. I follow the tutorial https://docs.nestjs.com/techniques/authentication and I don't get the 401 Unauthorized.
The text was updated successfully, but these errors were encountered: