Authored by 毕凯

App 判断逻辑修改

@@ -79,7 +79,7 @@ const common = { @@ -79,7 +79,7 @@ const common = {
79 refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), { 79 refer && !/signin|login|passport/.test(refer) && res.cookie('refer', encodeURI(refer), {
80 domain: 'yohobuy.com' 80 domain: 'yohobuy.com'
81 }); 81 });
82 - if (req.yoho.isApp || req.yoho.isMarsApp) { 82 + if (req.yoho.isApp) {
83 return next({ 83 return next({
84 code: 401, 84 code: 401,
85 message: 'weblogin', 85 message: 'weblogin',
@@ -55,18 +55,16 @@ module.exports = () => { @@ -55,18 +55,16 @@ module.exports = () => {
55 yoho.channel = channel; 55 yoho.channel = channel;
56 56
57 // 判断请求是否来自app 57 // 判断请求是否来自app
58 - yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') ||  
59 - (req.query.appVersion && req.query.appVersion !== 'false') ||  
60 - req.cookies.app_version || /YohoBuy/i.test(req.get('User-Agent') || ''); 58 + yoho.isMarsApp = /yohomars/i.test(req.get('User-Agent') || '');
  59 + yoho.isApp = yoho.isMarsApp ||
  60 + req.cookies.app_version ||
  61 + /YohoBuy/i.test(req.get('User-Agent') || '') ||
  62 + (req.query.app_version && req.query.app_version !== 'false') ||
  63 + (req.query.appVersion && req.query.appVersion !== 'false');
61 yoho.isMobile = /(nokia|iphone|android|ipad|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i.test(req.get('User-Agent') || ''); // eslint-disable-line 64 yoho.isMobile = /(nokia|iphone|android|ipad|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i.test(req.get('User-Agent') || ''); // eslint-disable-line
62 yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || ''); 65 yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || '');
63 yoho.isWeibo = /weibo/i.test(req.get('User-Agent') || ''); 66 yoho.isWeibo = /weibo/i.test(req.get('User-Agent') || '');
64 yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || ''); 67 yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || '');
65 - yoho.isMarsApp = /yohomars/i.test(req.get('User-Agent') || '');  
66 -  
67 - if (yoho.isMarsApp) {  
68 - yoho.isApp = false;  
69 - }  
70 68
71 Object.assign(res.locals, yoho); 69 Object.assign(res.locals, yoho);
72 Object.assign(req.yoho, yoho); 70 Object.assign(req.yoho, yoho);
@@ -8,7 +8,7 @@ const config = global.yoho.config; @@ -8,7 +8,7 @@ const config = global.yoho.config;
8 module.exports = () => { 8 module.exports = () => {
9 return (req, res, next) => { 9 return (req, res, next) => {
10 10
11 - if (!req.yoho.isApp && !req.yoho.isMarsApp) { 11 + if (!req.yoho.isApp) {
12 // 从 SESSION 中获取到当前登录用户的 UID 12 // 从 SESSION 中获取到当前登录用户的 UID
13 if (req.session && _.isNumber(req.session.LOGIN_UID)) { 13 if (req.session && _.isNumber(req.session.LOGIN_UID)) {
14 // 调用接口传参时切勿使用toString获得字符串 14 // 调用接口传参时切勿使用toString获得字符串