Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Authentication Client caching BadRequest responses from create #1947

Closed
nborko opened this issue May 5, 2020 · 3 comments · Fixed by #2892
Closed

Authentication Client caching BadRequest responses from create #1947

nborko opened this issue May 5, 2020 · 3 comments · Fixed by #2892

Comments

@nborko
Copy link

nborko commented May 5, 2020

I'm running the latest feathers version of everything, using the rest client with axios.

I have overridden the create method of my authentication service to return BadRequest in some cases. My issue is that after calling app.authenticate() and receiving the BadRequest error, subsequent calls to any other service also immediately returns the same BadRequest error without making an actual network request. Thus, I am unable to fall back to a non-authenticated service call when a login fails.

As far as I can tell, when the client runs calls the authentication hook in subsequent service calls, it keeps returning the same rejected promise stored in the authentication key (app.get('authentication'))

My current solution is to call app.authentication.reset() on the client side before making subsequent calls to a non-authenticated service. However, the documentation for the reset method reads, "Should not be called directly." Should I be doing something different?

Thanks

@jnardone
Copy link
Contributor

jnardone commented May 6, 2020

We've seen weird issues with our authentication service when it returns non-401 errors and client state, to the point where we now have an after hook on our auth services that convert all 400-level error codes to 401s.

#1787

@sradevski
Copy link

Just to add some more context based on what I observed. I think the reason for this is, feathers assumes that we first check for the token validity, reauthenticate, and only then do server requests. If you do some requests in parallel, as noted in the issue, even if they are done to routes that don't require auth, those will be rejected with the reAuthenticate rejection error, so it seems all other feathers client requests wait for the authentication call to resolve. Calling reset is not an option for me, since I don't know if the token is valid or not until I call reAuthenticate, and I don't want to needlessly logout the user.

@daffl
Copy link
Member

daffl commented Nov 24, 2022

This was indeed a bug and will be fixed with #2892

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants