Closed
Description
This happens e.g., when the client presents an invalid authorization token to the REST API, which will respond 500, and the interceptor that clears localStorage will not run.
To reproduce (using angularJS-generated model bindings)
- Log in using the AngularJS SDK-generated support code
- Edit the authorization token in the client browser - e.g., localStorage.$LoopBack$accessTokenId = "foo"
- Try to Log out in the client. The server will now respond 500 "invalid token" (or similar)
The interceptor code will not run, leaving the invalid token in localStorage, meaning we're stuck. User.isAuthenticated() will respond true, but calls will not be authorized. We need the interceptor to run even if the server presents a 500 invalid token. For the AngularJS SDK code:
"logout": {
interceptor: {
response: function(response) {
LoopBackAuth.clearUser();
LoopBackAuth.clearStorage();
return response.resource;
}
},