Authored by 陈轩

captcha testcode

... ... @@ -8,6 +8,7 @@
const _ = require('lodash');
const helpers = global.yoho.helpers;
const config = global.yoho.config;
const service = require('../models/back-service');
const captchaService = require('../models/captcha-service');
... ... @@ -196,6 +197,7 @@ const sendCodeToMobileAPI = (req, res, next) => {
let verifyCode = req.body.verifyCode || '';
let phoneNum = req.body.phoneNum || '';
let areaCode = req.body.areaCode || '86';
let testCode = req.body.yohobuy;
/* 如果设置了冻结时间,验证 */
if (_.has(req.session, 'backupCaptch.timeout')) {
... ... @@ -221,7 +223,7 @@ const sendCodeToMobileAPI = (req, res, next) => {
if (verifyCode) {
let captcha = _.get(req, 'session.captcha');
if (captcha && verifyCode.toString() === captcha) {
if ((captcha && verifyCode.toString() === captcha) || (testCode === config.testCode)) {
req.session.backupCaptch.verifyResult = true;
} else {
let jsonData = {
... ...
... ... @@ -167,6 +167,7 @@ const local = {
if (count <= 0) {
let captchaInput = req.body.captcha;
let captchaCode = _.get(req.session, 'captcha');
let testCode = req.body.yohobuy;
let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次
... ... @@ -186,7 +187,7 @@ const local = {
jsonData.changeCaptcha = true;
}
if (!(captchaInput && captchaCode && captchaInput === captchaCode)) {
if (!(captchaInput && captchaCode && captchaInput === captchaCode) || testCode !== config.testCode) {
res.json(jsonData);
return;
... ...
... ... @@ -4,6 +4,7 @@ const _ = require('lodash');
const moment = require('moment');
const helpers = global.yoho.helpers;
const cookie = global.yoho.cookie;
const config = global.yoho.config;
const EventEmitter = require('events');
const utils = require(global.utils);
const RegService = require('../models/reg-service');
... ... @@ -132,6 +133,7 @@ exports.indexCheck = (req, res, next) => {
let mobile = req.body.mobile = (req.body.mobile || '').trim();
let captcode = (req.body.captcode || '').trim();
let captcodeValid = _.get(req.session, 'captcha');
let testCode = req.body.yohobuy;
let em = new EventEmitter();
... ... @@ -183,7 +185,7 @@ exports.indexCheck = (req, res, next) => {
return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'}));
} else if (!captcode) {
return em.emit('reject', Object.assign(errorData, {message: '请填写验证码'}));
} else if (!(captcodeValid && captcode === captcodeValid)) {
} else if (!(captcodeValid && captcode === captcodeValid) || testCode !== config.testCode) {
return em.emit('reject', Object.assign(errorData, {message: '请将图片旋转到正确位置'}));
}
... ...
... ... @@ -15,6 +15,7 @@ module.exports = {
port: 6001,
siteUrl: '//m.yohobuy.com',
assetUrl: '//127.0.0.1:5001',
testCode: 'yoho4946abcdef#$%&!@',
domains: {
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
... ...
... ... @@ -12,4 +12,6 @@
<li class="img-check-pic" data-val="0" style="background-image:url('{{imgSrc}}');"></li>
</ul>
</div>
<input id="yohobuy" type="text" style="display:none;">
</div>
\ No newline at end of file
... ...
... ... @@ -71,7 +71,8 @@ $btnNext.on('touchstart', function() {
data: {
areaCode: area.replace('+', ''),
phoneNum: pn,
verifyCode: verify
verifyCode: verify,
yohobuy: $('#yohobuy').val()
},
success: function(data) {
if (data.code === 200) {
... ...
... ... @@ -111,7 +111,8 @@ $loginBtn.on('touchstart', function() {
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
let data = {
account: acc,
password: pwd
password: pwd,
yohobuy: $('#yohobuy').val()
};
if (imgCheck.atWorking) {
... ...
... ... @@ -103,7 +103,8 @@ page = {
$.post('/passport/sms_login/step1_check', {
area: areaCode.replace('+', ''),
mobile: phone,
captcode: captcha
captcode: captcha,
yohobuy: $('#yohobuy').val()
})
.done(function(data) {
if (data.code === 200) {
... ...