diff --git a/print/core/mixins/user-locale.js b/print/core/mixins/user-locale.js index f30bc0b28..2b9b0c8c5 100644 --- a/print/core/mixins/user-locale.js +++ b/print/core/mixins/user-locale.js @@ -4,6 +4,7 @@ const config = require('../config'); const fallbackLocale = config.i18n.fallbackLocale; const userLocale = { async serverPrefetch() { + console.log(this.auth); if (this.clientId) this.locale = await this.getLocale(this.clientId); @@ -24,8 +25,7 @@ const userLocale = { }); } }, - props: ['clientId'] + props: ['auth', 'clientId'] }; - Vue.mixin(userLocale); diff --git a/print/core/router.js b/print/core/router.js index 3be6cdd35..00a9821c1 100644 --- a/print/core/router.js +++ b/print/core/router.js @@ -28,6 +28,11 @@ module.exports = app => { if (!authToken || isTokenExpired(authToken.created, authToken.ttl)) throw new Error('Invalid authorization token'); + request.body.auth = { + userId: authToken.userId, + token: authorization + }; + next(); } catch (error) { next(error); diff --git a/print/methods/report.js b/print/methods/report.js index 117462d9e..52d97912b 100644 --- a/print/methods/report.js +++ b/print/methods/report.js @@ -2,17 +2,12 @@ const Report = require('../core/report'); module.exports = app => { app.get(`/api/report/:name`, async(req, res, next) => { - const args = req.query; - const requiredArgs = ['clientId']; - const argList = requiredArgs.join(','); - const hasRequiredArgs = requiredArgs.every(arg => { - return args[arg]; - }); + const query = req.query; + const body = re.body; + const args = Object.assign({}, req.query); + // merge params try { - if (!hasRequiredArgs) - throw new Error(`Required properties not found [${argList}]`); - const reportName = req.params.name; const fileName = getFileName(reportName, args); const report = new Report(reportName, args);