Authored by yyq

Merge remote-tracking branch 'origin/feature/imgcheck-sign' into release/0704

... ... @@ -49,9 +49,9 @@ global.utils = path.resolve('./utils');
global.appRoot = path.resolve(__dirname);
// 向模板注入变量
app.locals.devEnv = app.get('env') === 'development';
app.locals.isProduction = app.get('env') === 'production';
app.locals.version = pkg.version;
global.devEnv = app.locals.devEnv = app.get('env') === 'development';
global.isProduction = app.locals.isProduction = app.get('env') === 'production';
global.version = app.locals.version = pkg.version;
// zookeeper
if (config.zookeeperServer) {
... ...
... ... @@ -37,12 +37,12 @@ const generate = (req, res, next) => {
if (result.code === 200) {
request({
url: result.data.url,
headers: {
headers: Object.assign({
'X-request-ID': req.reqID || '',
'X-YOHO-IP': req.yoho.clientIp || '',
'X-Forwarded-For': req.yoho.clientIp || '',
'User-Agent': 'yoho/nodejs'
}
}, result.headers || {})
}).pipe(res);
}
... ...
... ... @@ -17,19 +17,30 @@ module.exports = class extends global.yoho.BaseModel {
gen(id) {
if (id) {
let qsstr = qs.stringify({
let params = {
udid: id,
fromPage: PAGE,
client_type: config.app,
app_version: config.appVersion
});
};
const headers = {};
if (!global.isProduction && config.yohoVerifyUdid) {
params.udid = global.yoho.verify.udid;
params = global.yoho.sign.apiSign(params);
const verifySign = global.yoho.verify ? global.yoho.verify.sign(params) : '';
return Promise.resolve({
headers['x-yoho-verify'] = verifySign;
}
const result = {
code: 200,
data: {
url: `${apiUrl}passport/img-check?${qsstr}`
}
});
url: `${apiUrl}passport/img-check?${qs.stringify(params)}`
},
headers
};
return Promise.resolve(result);
} else {
return Promise.reject({
code: 400,
... ...