Authored by htoooth

fix

... ... @@ -80,7 +80,7 @@ passport.use('local', new LocalStrategy({
}
};
done(null, {uid});
done(null, {uid, session_key: result.data.session_key});
} else {
errLoginTimes = errLoginTimes + 1;
accountTimes = accountTimes + 1;
... ...
... ... @@ -212,7 +212,18 @@ const bind = {
sourceType: sourceType + '_bind'
});
return loginService.syncUserSession(result.data.uid, req, res).then(() => {
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => {
return {code: 200, message: result.message, data: {refer: refer}};
});
} else {
... ... @@ -246,7 +257,18 @@ const bind = {
sourceType: sourceType + '_relate'
});
return loginService.syncUserSession(result.data.uid, req, res).then(() => {
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, result.data.session_key).then(() => {
return {code: 200, message: result.message, data: {refer: refer}};
});
} else {
... ...
... ... @@ -273,7 +273,18 @@ let mobileRegister = (req, res, next) => {
return res.json(data);
}
return loginService.syncUserSession(regResult.data.uid, req, res).then(() => {
let uid = {
toString() {
return this.uid;
},
uid: result.data.uid,
sessionKey: result.data.session_key,
isValid() {
return this.uid && this.sessionKey;
}
};
return loginService.syncUserSession(uid, req, res, regResult.data.session_key).then(() => {
return res.json({
code: 200,
message: '注册成功',
... ...
... ... @@ -62,6 +62,7 @@ const syncUserSession = (uid, req, res, sessionKey) => {
res.cookie('isStudent', isStudent, {
domain: config.cookieDomain
});
res.cookie('_SESSION_KEY', authcode(sessionKey, '_SESSION_KEY', AUTH_TIME, 'encode'), {
domain: config.cookieDomain
});
... ...
... ... @@ -17,14 +17,14 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// prod
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
//singleApi: 'http://single.yoho.cn/',
//api: 'http://api.yoho.cn/',
//service: 'http://service.yoho.cn/',
// gray
// singleApi: 'http://single.gray.yohops.com/',
... ...
... ... @@ -9,7 +9,7 @@ const authcode = require(`${global.utils}/authcode`);
// const cache = global.yoho.cache;
function decrypt(word) {
return authcode(word, '_SESSION_KEY');
return authcode(word, '_SESSION_KEY', 0, 'decode');
}
module.exports = () => {
... ... @@ -37,11 +37,12 @@ module.exports = () => {
return this.uid;
},
uid: cookie.getUid(req),
sessionKey: decrypt(req.cookies._SESSION_KEY),
sessionKey: decodeURIComponent(decrypt(req.cookies._SESSION_KEY)),
isValid() {
return this.uid && this.sessionKey;
}
};
}
// 记住我
... ...