Authored by htoooth

fix

... ... @@ -21,9 +21,7 @@ const _mustEqualAsync = (req) => {
});
}
let result = verifyCode.split('|');
return req.ctx(CaptchaServiceModel).check(id, result[1], result[0]);
return req.ctx(CaptchaServiceModel).check(id, verifyCode);
};
// 中间件
... ... @@ -45,9 +43,7 @@ const requiredAPI = (req, res, next) => {
// 七牛验证码
const generate = (req, res, next) => {
const from = req.query.from || 'page';
req.ctx(CaptchaServiceModel).generateCaptcha(req.session.id, from).then((result) => {
req.ctx(CaptchaServiceModel).generateCaptcha(req.session.id).then((result) => {
req.session.captchaCount = 0;
req.session.captchaTime = new Date().getTime();
... ...
... ... @@ -6,17 +6,19 @@
const apiUrl = global.yoho.config.domains.service;
const PAGE = 'pc';
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
gen(id, from) {
if (id && from) {
gen(id) {
if (id) {
return Promise.resolve({
code: 200,
data: {
url: `${apiUrl}passport/img-check.jpg?udid=${id}&fromPage=${from}`
url: `${apiUrl}passport/img-check.jpg?udid=${id}&fromPage=${PAGE}`
}
});
} else {
... ... @@ -27,12 +29,12 @@ module.exports = class extends global.yoho.BaseModel {
}
}
check(id, from, captcha) {
check(id, captcha) {
return this.get({
data: {
method: 'app.verified.graphic',
udid: id,
fromPage: from,
fromPage: PAGE,
degrees: captcha
}
});
... ...
... ... @@ -8,16 +8,16 @@ module.exports = class extends global.yoho.BaseModel {
this.api = new CaptchaApi(ctx);
}
generateCaptcha(id, from) {
return this.api.gen(id, from)
generateCaptcha(id) {
return this.api.gen(id)
.then(result => {
logger.info('get captcha from ', result.data.url);
return result;
});
}
check(id, page, captcha) {
return this.api.check(id, page, captcha).then((result) => {
check(id, captcha) {
return this.api.check(id, captcha).then((result) => {
if (result.code === 200) {
return {
code: 200,
... ...
... ... @@ -71,7 +71,7 @@ var Gift = {
}
};
captcha = new Captcha('.captcha-img', {page: 'gift'}).init();
captcha = new Captcha('.captcha-img').init();
require('../common');
... ...
... ... @@ -23,7 +23,7 @@ var sInt,
var baseQs;
var captcha = new Captcha('.captcha-safe-form-r', {page: 'validate'}).init();
var captcha = new Captcha('.captcha-safe-form-r').init();
require('../common');
... ...
... ... @@ -23,7 +23,7 @@ var $cr = $('#country-code-hide'),
$accErr = $('#account-err'),
caCount = 4, // 验证码位数
hasPh = false,
captcha = new Captcha('#captcha-img', {page: 'back2'}).init();
captcha = new Captcha('#captcha-img').init();
require('../../simple-header');
require('yoho-jquery-placeholder');
... ...
... ... @@ -13,7 +13,7 @@ var $sc = $('#send-captcha'),
$next = $('#next-step'),
seconds,
itime,
captcha = new Captcha('#captcha-img', {page: 'back'}).init();
captcha = new Captcha('#captcha-img').init();
require('../../simple-header');
... ...
... ... @@ -6,7 +6,7 @@
var $ = require('yoho-jquery');
var Captcha = require('../../plugins/captcha');
var captcha = new Captcha('#captcha', {page: 'cert'}).init();
var captcha = new Captcha('#captcha').init();
var dovalidate = false; // 校验验证码的标识
var isvalidatecode = false; // 是否验证成功的标识
var isvalidatepwd = false; // 密码验证是否通过的标识
... ...
... ... @@ -18,7 +18,7 @@ var $wrapper = $('.bindwrapper'),
$phoneTip = $wrapper.find('.phone-err-tip'),
$nextBtn = $wrapper.find('.yohobindbtn');
var captcha = new Captcha('#captcha', {page: 'bind2'}).init();
var captcha = new Captcha('#captcha').init();
var captcha2;
require('../../simple-header');
... ... @@ -356,7 +356,7 @@ function nextStep() {
$('#bindmobileform').attr('action', data.data.next);
$('#bindmobileform').submit();
} else if (data.code === 201) {
captcha2 = new Captcha('#captcha2', {page: 'bind'}).init();
captcha2 = new Captcha('#captcha2').init();
// 已注册 未绑定
username = data.data.user.username;
... ...
... ... @@ -55,7 +55,7 @@ var $accountInput1 = $('#account1'),
// 图像验证码
$passwordCaptchaWrap = $('.captcha-wrap'),
passwordCaptchaImg = new Captcha('.captcha-wrap', {checkURI: '', page: 'login'}).init(),
passwordCaptchaImg = new Captcha('.captcha-wrap', {checkURI: ''}).init(),
isShowCaptchaImg = false,
getPasswordCaptchaImgVal = function() {
if (isShowCaptchaImg) {
... ... @@ -75,7 +75,7 @@ var $accountInput1 = $('#account1'),
getCaptchaSmsTokenVal = function() { // 短信登录凭证
return $.trim($captchaSmsTokenHideInput.val());
},
smsCaptchaImg = new Captcha('.sms-captcha-img-wrap', {checkURI: '', page: 'login'}).init(),
smsCaptchaImg = new Captcha('.sms-captcha-img-wrap', {checkURI: ''}).init(),
getSmsCaptchaImgVal = function() { // 短信登录图形验证码
return smsCaptchaImg.getResults();
},
... ...
... ... @@ -13,7 +13,7 @@ var $registerPage = $('.register-page'),
$pwdTip1 = $pwdTips.find('#pwd-tip1'),
$errTip = $('#err-tip'),
$registerBtn = $('#register-btn'),
captchaImage = new Captcha('#captcha-img', {checkURI: '', page: 'reg'}).init();
captchaImage = new Captcha('#captcha-img', {checkURI: ''}).init();
var $sendCaptcha = $('#send-captcha'),
validateResult = [];
... ...
... ... @@ -93,7 +93,7 @@ Captcha.prototype = {
*/
refresh: function() {
var self = this;
var url = this.refreshURI + '?t=' + $.now() + '&from=' + this.page;
var url = this.refreshURI + '?t=' + $.now();
return $.sleep(500).then(function() {
if (self.running) {
... ... @@ -193,7 +193,7 @@ Captcha.prototype = {
result.push(this.$_____trojanYohobuy.val());
}
return result.join('') === '0000' ? '' : result.join(',') + '|' + this.page;
return result.join('') === '0000' ? '' : result.join(',');
},
/**
... ...