Authored by 陈峰

图片验证码日志

... ... @@ -14,6 +14,7 @@ const service = require('../models/back-service');
const captchaService = require('../models/captcha-service');
const SIGN_IN = helpers.urlFormat('/passport/login');
const logger = global.yoho.logger;
/**
* 通过邮箱找回密码页面
... ... @@ -210,6 +211,7 @@ const sendCodeToMobileAPI = (req, res, next) => {
if (verifyCode) {
let captcha = _.get(req, 'session.captcha');
logger.info(`验证码校验结果:${verifyCode.toString() === captcha},user:${verifyCode};server:${captcha}`);
if ((captcha && verifyCode.toString() === captcha) || (testCode === config.testCode)) {
req.session.backupCaptch.verifyResult = true;
} else {
... ...
... ... @@ -14,6 +14,7 @@ const AuthHelper = require('../models/auth-helper');
const _ = require('lodash');
const config = global.yoho.config;
const moment = require('moment');
const logger = global.yoho.logger;
const Sources = {
qq: 'QQ',
... ... @@ -96,6 +97,7 @@ const bind = {
if (verify) {
let captcha = _.get(req, 'session.captcha');
logger.info(`验证码校验结果:${verify.toString() === captcha},user:${verify};server:${captcha}`);
if ((captcha && verify.toString() === captcha) || (testCode === config.testCode)) {
BindService.bindCheck(phoneNum, openId, sourceType, areaCode).then(result => {
let data = {
... ... @@ -127,7 +129,7 @@ const bind = {
} else {
let jsonData = {
code: 400,
message: '请将图片旋转到正确位置'
message: '请将图片旋转到正确方向'
};
if (req.session.captchaValidCount === 0) {
... ...
... ... @@ -29,9 +29,17 @@ exports.get = (req, res, next) => {
exports.imgCheck = (req, res, next) => {
if (req.session.captchaSrc) {
return request(`${req.session.captchaSrc}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`)
.pipe(res);
}
return next();
return imgCheckAPI.gen().then(result => {
if (result.code === 200 && result.data) {
let codeStr = result.data.degrees.reduce((str, rotate) => {
return str.concat((4 - rotate / 90 % 4) % 4);
}, '');
req.session.captcha = codeStr;
req.session.captchaSrc = result.data.verifiedGraphicCode;
return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res);
}
next();
}).catch(next);
};
... ...
... ... @@ -17,6 +17,7 @@ const config = global.yoho.config;
const utils = require(global.utils);
const RegService = require('../models/reg-service');
const AuthHelper = require('../models/auth-helper');
const logger = global.yoho.logger;
const loginPage = `${config.siteUrl}/passport/login`;
... ... @@ -200,6 +201,8 @@ const local = {
captchaShow: true
};
logger.info(`验证码校验结果:${captchaInput.toString() === captchaCode},user:${captchaInput};server:${captchaCode}`);
--req.session.captchaValidCount;
if (!errorCount) {
... ...
... ... @@ -14,6 +14,7 @@ const helpers = global.yoho.helpers;
const sign = global.yoho.sign;
const cookie = global.yoho.cookie;
const config = global.yoho.config;
const logger = global.yoho.logger;
const RegService = require('../models/reg-service');
const AuthHelper = require('../models/auth-helper');
const captchaService = require('../models/captcha-service');
... ... @@ -141,6 +142,7 @@ let verifyMobile = (req, res, next) => {
req.session.captcha = null;
data.changeCaptcha = true;
}
logger.info(`验证码校验结果:${captcha.toString() === diffCaptcha},user:${captcha};server:${diffCaptcha}`);
// error case: 验证码不匹配
if (!(captcha === diffCaptcha || testCode === config.testCode)) {
... ...
... ... @@ -10,6 +10,7 @@ const utils = require(global.utils);
const RegService = require('../models/reg-service');
const PhoneService = require('../models/phone-service');
const AuthHelper = require('../models/auth-helper');
const logger = global.yoho.logger;
// constrant
const CODE_REQUIRED = '请输入校验码';
... ... @@ -205,6 +206,7 @@ exports.indexCheck = (req, res, next) => {
}
logger.info(`验证码校验结果:${captcode.toString() === captcodeValid},user:${captcode};server:${captcodeValid}`);
// 验证
if ([area, mobile].some(val => val === '')) {
return em.emit('reject', Object.assign(errorData, { message: '请填写手机号'}));
... ... @@ -215,7 +217,7 @@ exports.indexCheck = (req, res, next) => {
(captcodeValid && captcode === captcodeValid) || (testCode === config.testCode)
)
) {
return em.emit('reject', Object.assign(errorData, {message: '请将图片旋转到正确位置'}));
return em.emit('reject', Object.assign(errorData, {message: '请将图片旋转到正确方向'}));
}
// congratulation~~
... ...
... ... @@ -74,7 +74,7 @@ $btnNext.on('touchstart', function() {
captcha = imgCheck.getResults();
if (captcha === '0000') {
tip.show('请将图片旋转到正确位置');
tip.show('请将图片旋转到正确方向');
return false;
}
... ...
... ... @@ -121,7 +121,7 @@ page = {
}
// if (captcha === '0000') {
// tip.show('请将图片旋转到正确位置');
// tip.show('请将图片旋转到正确方向');
// return;
// }
... ...
... ... @@ -84,10 +84,8 @@ ImgCheck.prototype = {
this.picWidth = this.useREM.picWidth / this.useREM.rootFontSize;
}
this.refresh().done(function() {
self.bindEvents();
});
this.refresh();
self.bindEvents();
this.atWorking = true;
},
... ... @@ -150,17 +148,8 @@ ImgCheck.prototype = {
*/
refresh: function() {
const self = this;
let uri = this.refreshURI + '?' + Date.now();
return $.get(uri)
.done(function(data) {
let src = data.src;
self.render({
imgSrc: src
});
})
.fail($.noop);
self.render({imgSrc: `/passport/img-check.jpg?t=${Date.now()}`});
},
... ...