Skip to content

Logout does not clear localStorage (AngularJS) when backend logout fails #1081

Closed
@thovden

Description

@thovden

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)

  1. Log in using the AngularJS SDK-generated support code
  2. Edit the authorization token in the client browser - e.g., localStorage.$LoopBack$accessTokenId = "foo"
  3. 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;
            }
          },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions