Authored by 周少峰

update session key

... ... @@ -10,6 +10,17 @@ const passport = require('passport');
const uuid = require('uuid');
const log = global.yoho.logger;
const userService = require('../models/user-service');
const config = global.yoho.config;
const authcode = require(`${global.utils}/authcode`);
const AUTH_TIME = 2592000000;
const updateSessionKey = (res, sessionKey) => {
if (sessionKey) {
res.cookie('_SESSION_KEY', authcode(sessionKey, '_SESSION_KEY', AUTH_TIME, 'encode'), {
domain: config.cookieDomain
});
}
}
function bindSuccess(res, type) {
return res.render('home/user/bind-result', {
... ... @@ -36,7 +47,9 @@ function bindFail(res, message, type) {
const bind3party = (req, res, user) => {
userService.bind3partyAccount(req.user.uid, user)
.then(ret => {
if (ret && ret.code === 200) {
updateSessionKey(res, _.get(ret, 'data.session_key', ''));
return bindSuccess(res, user.sourceType);
}
return bindFail(res, ret && ret.message, user.sourceType);
... ...