Closed isnifer closed 6 months ago
If I understand correctly, the reported breakage is about the "or" function being called in parallel, instead of sequentially?
@mcollina you're totally right
How is that a problem?
@mcollina I want to check second path only then first path is failed.
@mcollina imagine:
@mcollina so, the problem is — if it fails in User path, it doesn't care about Admin case, btw User path should not be called at all.
Can you please craft an example to reproduce that case? Something that would pass before and fail now? Thx
@mcollina yes, sure. I'll do it on Monday
@isnifer @mcollina Here's the PR with a fix and an additional test: https://github.com/fastify/fastify-auth/pull/224
@isnifer Could you please verify that this PR resolves the issue you're having?
@mcollina repro is here https://github.com/isnifer/fastify-issue-217-example
I tested PR from @yakovenkodenis — it works!
Prerequisites
Fastify version
4.26.1
Plugin version
4.5.0
Node.js version
20.11.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.3.1 (23D60)
Description
217 introduced new rules for auth.
The main problem is that now both paths (in
or
relation) going in parallel instead of waiting until the first path will fail. I commented all tests except one that clearly showing a problem (and my own production code solution too).Steps to Reproduce
cd fastify-auth
)npm i
)npm t
)or
relation "THIS IS A SECOND AUTH PATH SHOULD NOT BE CALLED" but you SHOULDN'T.THE ONLY ROUTE
TWO AUTH HANDLERS UPDATED WITH "CONSOLE.LOG"
THE ONLY TEST WHERE "verifyBigAsync" is passing, BUT "verifyOddAsync" called to
Logs from the terminal
Expected Behavior
No response