Closed jgaehring closed 4 years ago
I think we need to expand this code to catch for "empty" tokens: https://github.com/farmOS/farmOS.js/blob/14bab48c10e6c3b8b96067268b3c0747d9258a16/index.js#L108
As far as the error handling, I haven't been able to take a close look, but I agree it seems like 400
errors should be caught?
Ok, so I think we found some things that can be improved, but practically speaking it looks like we don't really need to be on guard against tokens being deleted in this way, since it shouldn't happen in practice. We can, however, take some precautionary steps to make sure at least this error is propagated to the user by making sure we throw
all errors so they can be caught and handled by the application code. I'm going to commit some changes to this effect and publish farmos@0.1.2 to npm, and pull those into Field Kit.
Resolved by 0845aec.
I'm not sure if this behavior would be different if an actual invalid token was present, but below is how I simulated such a state on the current develop build using Chrome browser.
Steps to Reproduce
token
's value column and select "Edit Value".access_token
andrefresh_token
with an empty string.Expected Result
The app should reroute the user to the Login page. (and maybe display the cause of the login error?)
Observed Result
Nothing. No error is displayed, and the user is not rerouted to login. If you open the console you see several failed network requests, which have 403'ed, followed by one request to
/oauth2/token
which has responded400 (Bad Request)
.I'm a little surprised that the 400 didn't trigger a reroute, b/c I'd actually encountered something similar before, which I believed I had fixed with 92f60be. So I guess we need to work on the error handling some more here.