2018-10-24 21:42:33 +08:00
|
|
|
'use strict';
|
|
|
|
|
2018-02-22 19:22:39 +08:00
|
|
|
module.exports = function connectionParams (userDatabaseService) {
|
|
|
|
return function connectionParamsMiddleware (req, res, next) {
|
2018-06-05 19:21:56 +08:00
|
|
|
const { user, api_key: apikeyToken, authorizationLevel } = res.locals;
|
2018-02-22 19:22:39 +08:00
|
|
|
|
2018-06-05 19:21:56 +08:00
|
|
|
userDatabaseService.getConnectionParams(user, apikeyToken, authorizationLevel,
|
2018-02-22 22:59:13 +08:00
|
|
|
function (err, userDbParams, authDbParams) {
|
2020-06-30 23:42:59 +08:00
|
|
|
req.profiler.done('getConnectionParams');
|
2018-02-22 19:22:39 +08:00
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
}
|
2018-02-22 19:22:39 +08:00
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
res.locals.userDbParams = userDbParams;
|
|
|
|
res.locals.authDbParams = authDbParams;
|
2018-02-22 19:22:39 +08:00
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
next();
|
|
|
|
});
|
2018-02-22 19:22:39 +08:00
|
|
|
};
|
|
|
|
};
|