Some changes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-31 08:18:10 +02:00
parent 50c6c2d87b
commit e826cdfee4
3 changed files with 11 additions and 11 deletions

View File

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

View File

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

View File

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