Errores en servicio de autenficación solucionados.

This commit is contained in:
Joan Sanchez 2017-10-04 13:27:38 +02:00
parent 245112438e
commit 9ebd705aea
1 changed files with 13 additions and 4 deletions

View File

@ -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
});
}