remove auth with url

This commit is contained in:
Matteo Pagliazzi
2018-08-15 10:40:25 +02:00
parent 2a7dfff88a
commit 696121fb24
7 changed files with 16 additions and 44 deletions

View File

@@ -97,26 +97,3 @@ export function authWithSession (req, res, next) {
})
.catch(next);
}
export function authWithUrl (req, res, next) {
let userId = req.query._id;
let apiToken = req.query.apiToken;
// Always allow authentication with headers
if (!userId || !apiToken) {
if (!req.header('x-api-user') || !req.header('x-api-key')) {
return next(new NotAuthorized(res.t('missingAuthParams')));
} else {
return authWithHeaders()(req, res, next);
}
}
return User.findOne({ _id: userId, apiToken }).exec()
.then((user) => {
if (!user) throw new NotAuthorized(res.t('invalidCredentials'));
res.locals.user = user;
return next();
})
.catch(next);
}