Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

Issue with setting endOnError : false, is throwing "Cannot read property 'getGroups' of undefined" #8

@danscrima

Description

@danscrima

I'm setting up an angular express app using stormpath-sdk-angularjs. The default endOnError: true isn't allowing my angular app to redirect to the login screen in two separate cases of when a user just needs to be authenticated, and also when a user needs to be authorized in a certain group. It looks like it's failing on the /api/users/current call and returning the error below.

I also do not have sp:{ waitForUser: true } set on my home state.

var spMiddleware = stormpathExpressSdk.createMiddleware({
  apiKeyId: config.stormpath.STORMPATH_API_KEY_ID,
  apiKeySecret: config.stormpath.STORMPATH_API_KEY_SECRET,
  appHref: config.stormpath.STORMPATH_APP_HREF,
  endOnError: false
});

This is what gets thrown on the server side:

TypeError: Cannot read property 'getGroups' of undefined
    at MiddlewareContext.currentUser (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/lib/middleware/currentUser.js:8:31)
    at MiddlewareContext.corsHandler (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/lib/middleware/corsHandler.js:15:3)
    at MiddlewareContext.corsPrefilter [as currentUser] (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/index.js:81:25)
    at Layer.handle [as handle_request] (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/route.js:131:13)
    at MiddlewareContext.handleAuthenticationError (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/lib/MiddlewareContext.js:122:7)
    at MiddlewareContext.authenticate (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/lib/middleware/authenticate.js:15:13)
    at MiddlewareContext.corsHandler (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/lib/middleware/corsHandler.js:15:3)
    at MiddlewareContext.corsPrefilter [as authenticate] (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/stormpath-sdk-express/index.js:81:25)
    at Layer.handle [as handle_request] (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/layer.js:95:5)
    at /home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/index.js:330:12)
    at next (/home/dscrima/whoadan/elite-technique-crossfit/node_modules/express/lib/router/index.js:271:10)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions