Authored by 陈峰

Merge branch 'feature/session2' into 'release/5.6'

sessionkey 低版本验证



See merge request !506
... ... @@ -13,25 +13,6 @@ const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const urlP = require('url');
/**
* 处理旧版本的app兼容新接口
* @param {*} url url
* @param {*} data data
* @param {*} param param
* @param {*} method method
*/
const middleApi = (url, data, param, method) => {
try {
let promise = method === 'post' ? api.post : api.get;
if (!_.get(data, 'uid.sessionKey', '') && data.uid) {
data.app_version = '5.5.0';
}
return promise.call(api, url, data, param);
} catch (err) {
return null;
}
};
const getResource = code => {
return serviceApi.get('operations/api/v5/resource/get', {
content_code: code,
... ... @@ -39,43 +20,43 @@ const getResource = code => {
});
};
const vip = (limit) => {
return middleApi('', {
return api.get('', {
method: 'app.student.vip',
limit: limit || 60
});
};
const verifiedStudentTotal = () => {
return middleApi('', {
return api.get('', {
method: 'app.student.verifiedStudentTotal'
});
};
const getProvince = () => {
return middleApi('', {
return api.get('', {
method: 'app.studentMarket.getAddressList'
}, {
cache: true
});
};
const getSchool = code => {
return middleApi('', {
return api.get('', {
method: 'app.studentMarket.getSchoolInfoList',
areaCode: code
});
};
const getEducationLevelList = () => {
return middleApi('', {
return api.get('', {
method: 'app.studentMarket.getEducationLevelList'
});
};
const userAcquireStatus = (uid, couponIds) => {
return middleApi('', {
return api.get('', {
method: 'app.coupons.userAcquireStatus',
uid: uid,
couponIds: couponIds
});
};
const verifyStudent = (uid, collegename, educationdegree, enrollmentyear) => {
return middleApi('', {
return api.get('', {
method: 'app.student.verifyStudent',
uid: uid,
client_type: 'h5',
... ... @@ -85,7 +66,7 @@ const verifyStudent = (uid, collegename, educationdegree, enrollmentyear) => {
});
};
const verifyIdentity = (uid, certno, name, pageurl) => {
return middleApi('', {
return api.get('', {
method: 'app.student.verifyIdentity',
uid: uid,
client_type: 'h5',
... ... @@ -101,7 +82,7 @@ const getUser = (uid) => {
data: {}
});
}
return middleApi('', {
return api.get('', {
method: 'app.passport.profile',
uid: uid
}, {
... ... @@ -153,7 +134,7 @@ const getPlatForm = (req) => {
if (isProduction) {
yoho.http = 'https:';
}
yoho.uid = req.user.uid;
yoho.uid = req.user.uid || req.query.uid;
yoho.isLogin = yoho.uid ? true : false;
return co(function*() {
let data = yield getUser(yoho.uid);
... ... @@ -391,7 +372,7 @@ exports.verifyidentity = (req, res, next) => {
// 添加分享成功记录
const addStudent = (ownuid, shareId) => {
return middleApi('', {
return api.get('', {
method: 'app.student.addShare',
uid: ownuid,
shareUid: shareId
... ...
... ... @@ -738,6 +738,9 @@ const setMasterCard = (req, res, next) => {
};
const sessionKeyAuth = (req, res, next) => {
if (!req.user.uid && req.query.uid) {
req.user.uid = req.query.uid;
}
next();
};
... ...
... ... @@ -14,8 +14,8 @@ const domains = {
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
global: 'http://api-global.yohobuy.com',
// liveApi: 'http://api.live.yoho.cn/',
... ...
... ... @@ -49,6 +49,30 @@ module.exports = () => {
appSessionType: req.cookies.app_client_type
};
}
if (!req.user.uid &&
(req.query.uid || (
req.cookies.app_uid &&
req.cookies.app_uid !== '0' &&
req.cookies.app_version &&
req.cookies.app_client_type
))
) {
let appUid = req.query.uid || req.cookies.app_uid;
let appVersion = req.query.app_version || req.cookies.app_version;
let appSessionType = req.query.client_type || req.cookies.app_client_type;
req.query.uid = {
toString: () => {
return _.parseInt(appUid);
},
appVersion: appVersion,
appSessionType: appSessionType
};
res.cookie('app_uid', appUid.toString());
res.cookie('app_version', appVersion);
res.cookie('app_client_type', appSessionType);
}
next();
};
};
... ...
... ... @@ -50,7 +50,7 @@
"xml2js": "^0.4.17",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.2.18",
"yoho-node-lib": "=0.2.20",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
... ...