-
Notifications
You must be signed in to change notification settings - Fork 176
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
Router runs middleware on routes, which are not in array. #46
Comments
Maybe specify the route for signin before declaring this middleware. |
Another possibility is to declare different routers for your different concerns. In a specific router, Koa-router won't execute a middleware if there's no matching route. (I'd like to change this behavior in #44 though). |
But if I will declare /signin route before declaring middleware, then middleware |
Thank you for your advise, will think about it, may be it will be a solution. |
I haven't worked with passport since ages so I can't advise more :-) |
Passport is just another middleware as well as controller 🙂 |
I've just found https://github.com/Foxandxss/koa-unless that might be interesting for your use case. |
@julienw I really need this behaviour, how do I achieve this. I am using different auth middleware in different routers and all of them get called for some reason. see #90 (comment) |
The problem in #90 is that both routes match the first middleware, so the behavior I'm mentioning doesn't work for this case. |
node.js version: v10.16.3
npm/yarn and version: 6.13.4
@koa/router
version: 8.0.5koa
version: 2.11.0Code sample:
Expected Behavior:
Expected, that route '/' will effect exactly for route '/', when using:
router.use([ '/signout', '/', '/update', '/password/change', '/email/change/request' ], guard.user.passport('jwt'), guard.csrf())
So that passport middleware should run exactly on those routes, which are is this array.
Actual Behavior:
Unfortunately route '/' in the array of routes above effects on any other route, even on
'/signin'
, which is not in array for passport middleware.Additional steps, HTTP request details, or to reproduce the behavior or a test case:
The text was updated successfully, but these errors were encountered: