diff --git a/services/auth/server/boot/routes.js b/services/auth/server/boot/routes.js index 2bb25ef34..39864da20 100644 --- a/services/auth/server/boot/routes.js +++ b/services/auth/server/boot/routes.js @@ -10,7 +10,7 @@ module.exports = function(app) { }); app.post('/login', function(req, res) { - let user = req.body.user; + let user = req.body.user ? req.body.user : ""; let password = req.body.password; let syncOnFail = true; let usesEmail = user.indexOf('@') !== -1; @@ -38,15 +38,24 @@ module.exports = function(app) { return; } - let query = url.parse(req.body.location, true).query; - let loginUrl = applications[query.apiKey]; + let parsedLocation; + let loginUrl; + let shouldContinue = false; + if (req.body.location) + parsedLocation = url.parse(req.body.location, true); + + if (parsedLocation && parsedLocation.query) { + loginUrl = applications[parsedLocation.query.apiKey]; + shouldContinue = parsedLocation.query.continue; + } + if (!loginUrl) loginUrl = applications.default; res.json({ token: token.id, - continue: query.continue, + continue: shouldContinue, loginUrl: loginUrl }); }