Authored by shijian

Merge branch 'feature/safe-bug' of http://git.yoho.cn/fe/yoho-blk into feature/safe-bug

... ... @@ -265,7 +265,7 @@ const modifyType = (req, res, next) => {
const edit = (req, res, next) => {
let type = req.params.type;
if (Number(cookieHelper.getVal(req, type + '_STEP')) !== 1) {
if (Number(cookieHelper.getVal(req, type + '_STEP')) !== 1 || !req.session.safeAccount) {
res.redirect(helpers.urlFormat('/me/setting/step1/' + type));
return;
}
... ... @@ -363,6 +363,10 @@ const validate1 = (req, res, next) => {
}
if (a) {
if (a.code === 200) {
req.session.safeAccount = true;
}
cookieHelper.setVal(res, req.body.type + '_STEP', 1);
res.send(a);
}
... ...
... ... @@ -218,6 +218,9 @@ const bindCheck = (req, res, next) => {
} else if (result.code === 200 && result.data.is_register === 1) {
return UserService.getUserInfoAsync(area, mobile).then(user => {
// 绑定流程:code=201 已注册 绑定过其他第三方
req.session.thirdBind = {
mobile: mobile
};
return { code: 201, message: result.message, data: { user: user } };
});
} else if (result.code === 200 && result.data.is_register === 3) {
... ... @@ -284,25 +287,29 @@ const bindMobile = (req, res, next) => {
let sourceType = _.trim(req.body.sourceType);
let password = _.trim(req.body.password) || '';
BindService.bindMobileAsync(openId, sourceType, mobile, area, password).then(result => {
if (result && result.code) {
if (result.code === 200 && result.data && result.data.uid) {
let refer = helpers.urlFormat('/passport/thirdlogin/bindsuccess', {
sourceType: sourceType + '_bind'
});
return LoginService.syncUserSession(result.data.uid, req, res).then(() => {
return { code: 200, message: result.message, data: { refer: refer } };
});
if (req.session.thirdBind && req.session.thirdBind.mobile === mobile) {
BindService.bindMobileAsync(openId, sourceType, mobile, area, password).then(result => {
if (result && result.code) {
if (result.code === 200 && result.data && result.data.uid) {
let refer = helpers.urlFormat('/passport/thirdlogin/bindsuccess', {
sourceType: sourceType + '_bind'
});
return LoginService.syncUserSession(result.data.uid, req, res).then(() => {
return { code: 200, message: result.message, data: { refer: refer } };
});
} else {
return { code: result.code, message: result.message, data: { refer: '' } };
}
} else {
return { code: result.code, message: result.message, data: { refer: '' } };
return { code: 400, message: '', data: '' };
}
} else {
return { code: 400, message: '', data: '' };
}
}).then(result => {
res.json(result);
}).catch(next);
}).then(result => {
res.json(result);
}).catch(next);
} else {
res.json({ code: 400, message: '', data: '' });
}
};
/**
... ...