Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
don't attach the middleware in stormpath.init()
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyej committed Feb 22, 2016
1 parent fd2e0b7 commit 28bc805
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/stormpath.js
Expand Up @@ -90,6 +90,12 @@ module.exports.init = function (app, opts) {
helpers.getUser(req, res, next);
}

// This middleware is used for backwards compatibility
// when stormpath.init() is wrapped with an app.use().
function nopMiddleware(req, res, next) {
next();
}

// Build routes.
client.on('ready', function () {
var config = app.get('stormpathConfig');
Expand Down Expand Up @@ -118,11 +124,11 @@ module.exports.init = function (app, opts) {
}

function addGetRoute(path, controller) {
router.get(path, bodyParser.forceDefaultBody(), controller);
router.get(path, bodyParser.forceDefaultBody(), stormpathMiddleware, controller);
}

function addPostRoute(path, controller, options) {
router.post(path, bodyParser.formOrJson(options), controller);
router.post(path, bodyParser.formOrJson(options), stormpathMiddleware, controller);
}

router.use(localsMiddleware);
Expand Down Expand Up @@ -223,9 +229,8 @@ module.exports.init = function (app, opts) {

app.use(awaitClientReadyMiddleware);
app.use('/', router);
app.use(stormpathMiddleware);

return stormpathMiddleware;
return nopMiddleware;
};

/**
Expand Down

0 comments on commit 28bc805

Please sign in to comment.