josx / ra-data-feathers

A feathers rest client for react-admin
MIT License
157 stars 53 forks source link

Logging out on 403 errors #111

Closed dinodeSimon closed 5 years ago

dinodeSimon commented 5 years ago

We are working with an API that sends a 403 HTTP status code when trying to delete an item that a user doesn't have permissions to delete. Currently the auto provider is seeing this 403 response and logging the user out completely.

Looking back through the history the addition of the piece of code to log the users out on 403 responses in addition to 401 was added to the auth provider a year ago.

https://github.com/josx/ra-data-feathers/commit/574ee17ac4028407eb32983dc08293c31840dcfe

Is it possible to change this so that the http codes which trigger a logout can be passed in with the options? That way we choose to log out on 401 responses and handle 403 responses for a particular item rather than logging the user out.

josx commented 5 years ago

Ok, what do you think if we can add it as an option? Can you make a PR with that?

dinodeSimon commented 5 years ago

Hi José,

No problems, we will have a think about a neat way to do it and put a PR up in the next couple of days.

TheHyphen commented 5 years ago

Hi, we've made a PR here: https://github.com/josx/ra-data-feathers/pull/112 Any thoughts?

josx commented 5 years ago

@TheHyphen I have merged you code, I think will help @dinodeSimon

TheHyphen commented 5 years ago

Thank you! When do you think this change might make it to an npm release?

josx commented 5 years ago

Here v2.2.1

TheHyphen commented 5 years ago

Thanks a ton! ✌️