Authored by 郭成尧

bind-bug-fixed

... ... @@ -99,14 +99,14 @@ const bind = {
if (result.code === 200) {
let nextUrl = helpers.urlFormat('/passport/bind/code', {
isReg: result.data.is_register, // esline-disable-line
is_register: result.data.is_register,
openId: openId,
sourceType: sourceType,
areaCode: areaCode,
phoneNum: phoneNum
});
data.data.isReg = result.data.is_register;
data.data.is_register = result.data.is_register;
data.data.next = nextUrl;
} else {
data.data = result.data;
... ...
... ... @@ -8,8 +8,6 @@
const _ = require('lodash');
const config = global.yoho.config;
const co = Promise.coroutine;
const cache = global.yoho.cache;
const log = global.yoho.logger;
const geetest = require('./geetest');
const captcha = require('./captcha');
const imgCheck = require('../models/imgcheck');
... ... @@ -60,48 +58,25 @@ const check = (req, res, next) => {
req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
co(function* () {
// 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码
if (req.path === '/passport/login/auth') {
// 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示
let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false);
log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`);
if (firstLoginShowCaptcha) {
req.yoho.captchaShow = true;
res.locals.useGeetest = _.get(req.app.locals.wap, 'geetest.validation', false); // 使用极验证
if (res.locals.useGeetest) {
req.yoho.captchaShow = false;
} else {
let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);
log.info(`Check clientip ${req.yoho.clientIp} status is ` + hasErrorLog);
let isNeedImgCheckApiData = yield req.ctx(imgCheck).isNeedImgCheck(req.sessionID);
if (hasErrorLog) {
req.yoho.captchaShow = true;
} else {
req.yoho.captchaShow = false;
}
if (_.parseInt(_.get(isNeedImgCheckApiData, 'code')) === 200) {
req.yoho.captchaShow = _.get(isNeedImgCheckApiData, 'data');
}
}
return req.yoho.captchaShow;
})().catch(function() {
// memcache 不可用,展示验证码
req.yoho.captchaShow = true;
return req.yoho.captchaShow;
}).then(function() {
})().then(function() {
// 不是账号密码登录,直接根据配置总开关决定是否需要展示验证码
if (!req.yoho.captchaShow) {
return next();
}
// 使用极验证
let useGeetest = _.get(req.app.locals.wap, 'geetest.validation', false);
// 某次请求极验证调用注册失败,强制使用自有图形验证码
if (req.session.useYohoCaptcha) {
useGeetest = false;
}
return (useGeetest ? geetest : captcha).validate(req, res, next);
return (res.locals.useGeetest ? geetest : captcha).validate(req, res, next);
});
};
... ...
... ... @@ -8,6 +8,7 @@
'use strict';
const FROM = require('../../../config/from');
const PAGE = 'H5';
class BindServiceModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -33,7 +34,8 @@ class BindServiceModel extends global.yoho.BaseModel {
mobile: params.mobile,
area: params.area,
udid: params.udid,
degrees: params.captcha
degrees: params.captcha,
fromPage: PAGE
}
});
}
... ...
... ... @@ -62,6 +62,7 @@ function nextStep(url, mobileNo, areaCode) {
url: '/passport/bind/sendBindMsg',
data: params,
success: function(res) {
requested = false;
if (res.code === 200) {
// 统计代码:用于统计从哪个渠道登录
... ... @@ -73,6 +74,7 @@ function nextStep(url, mobileNo, areaCode) {
location.href = url;
} else {
$btnNext.removeClass('disable').html('下一步');
tip.show(res.message);
}
},
... ... @@ -135,7 +137,8 @@ $btnNext.on('touchstart', function() {
leftBtnText: '更换号码',
rightBtnText: '继续绑定'
}
}, function() {
}, () => {
dialog.hideDialog();
nextStep(res.data.next, pn, areaCode);
});
} else if (res.data.is_register === 3) {
... ...