Merge remote-tracking branch 'origin/feature/imgcheck-sign' into release/0704
Showing
3 changed files
with
22 additions
and
11 deletions
@@ -49,9 +49,9 @@ global.utils = path.resolve('./utils'); | @@ -49,9 +49,9 @@ global.utils = path.resolve('./utils'); | ||
49 | global.appRoot = path.resolve(__dirname); | 49 | global.appRoot = path.resolve(__dirname); |
50 | 50 | ||
51 | // 向模板注入变量 | 51 | // 向模板注入变量 |
52 | -app.locals.devEnv = app.get('env') === 'development'; | ||
53 | -app.locals.isProduction = app.get('env') === 'production'; | ||
54 | -app.locals.version = pkg.version; | 52 | +global.devEnv = app.locals.devEnv = app.get('env') === 'development'; |
53 | +global.isProduction = app.locals.isProduction = app.get('env') === 'production'; | ||
54 | +global.version = app.locals.version = pkg.version; | ||
55 | 55 | ||
56 | // zookeeper | 56 | // zookeeper |
57 | if (config.zookeeperServer) { | 57 | if (config.zookeeperServer) { |
@@ -37,12 +37,12 @@ const generate = (req, res, next) => { | @@ -37,12 +37,12 @@ const generate = (req, res, next) => { | ||
37 | if (result.code === 200) { | 37 | if (result.code === 200) { |
38 | request({ | 38 | request({ |
39 | url: result.data.url, | 39 | url: result.data.url, |
40 | - headers: { | 40 | + headers: Object.assign({ |
41 | 'X-request-ID': req.reqID || '', | 41 | 'X-request-ID': req.reqID || '', |
42 | 'X-YOHO-IP': req.yoho.clientIp || '', | 42 | 'X-YOHO-IP': req.yoho.clientIp || '', |
43 | 'X-Forwarded-For': req.yoho.clientIp || '', | 43 | 'X-Forwarded-For': req.yoho.clientIp || '', |
44 | 'User-Agent': 'yoho/nodejs' | 44 | 'User-Agent': 'yoho/nodejs' |
45 | - } | 45 | + }, result.headers || {}) |
46 | }).pipe(res); | 46 | }).pipe(res); |
47 | } | 47 | } |
48 | 48 |
@@ -17,19 +17,30 @@ module.exports = class extends global.yoho.BaseModel { | @@ -17,19 +17,30 @@ module.exports = class extends global.yoho.BaseModel { | ||
17 | 17 | ||
18 | gen(id) { | 18 | gen(id) { |
19 | if (id) { | 19 | if (id) { |
20 | - let qsstr = qs.stringify({ | 20 | + let params = { |
21 | udid: id, | 21 | udid: id, |
22 | fromPage: PAGE, | 22 | fromPage: PAGE, |
23 | client_type: config.app, | 23 | client_type: config.app, |
24 | app_version: config.appVersion | 24 | app_version: config.appVersion |
25 | - }); | 25 | + }; |
26 | + const headers = {}; | ||
27 | + | ||
28 | + if (!global.isProduction && config.yohoVerifyUdid) { | ||
29 | + params.udid = global.yoho.verify.udid; | ||
30 | + params = global.yoho.sign.apiSign(params); | ||
31 | + const verifySign = global.yoho.verify ? global.yoho.verify.sign(params) : ''; | ||
26 | 32 | ||
27 | - return Promise.resolve({ | 33 | + headers['x-yoho-verify'] = verifySign; |
34 | + } | ||
35 | + const result = { | ||
28 | code: 200, | 36 | code: 200, |
29 | data: { | 37 | data: { |
30 | - url: `${apiUrl}passport/img-check?${qsstr}` | ||
31 | - } | ||
32 | - }); | 38 | + url: `${apiUrl}passport/img-check?${qs.stringify(params)}` |
39 | + }, | ||
40 | + headers | ||
41 | + }; | ||
42 | + | ||
43 | + return Promise.resolve(result); | ||
33 | } else { | 44 | } else { |
34 | return Promise.reject({ | 45 | return Promise.reject({ |
35 | code: 400, | 46 | code: 400, |
-
Please register or login to post a comment