Authored by htoooth

add captcha

... ... @@ -50,12 +50,6 @@ passport.use('local', new LocalStrategy({
return done({message: '登录参数错误'}, null);
}
let verifyCode = req.body.captcha;
if (verifyCode && verifyCode !== req.session.captcha) {
return done({message: '验证码不正确或验证码过期', needCaptcha: true}, null);
}
let shoppingKey = cookie.getShoppingKey(req);
let account = req.body.account;
... ...
... ... @@ -35,7 +35,7 @@ router.post('/passport/login/qrcode/refresh', login.local.qrcode.refresh);
router.post('/passport/login/qrcode/check', login.local.qrcode.check); // 验证二维码的状态
router.get('/passport/login', login.common.beforeLogin, login.local.loginPage);
router.post('/passport/login/auth', login.local.login);
router.post('/passport/login/auth', captcha.requiredAPI, login.local.login);
router.get('/passport/logout', login.local.logout);
// 微信登录
... ...
... ... @@ -55,7 +55,7 @@
</span>
</li>
<li class="clearfix captcha-wrap hide">
<li class="clearfix captcha-wrap">
</li>
<li class="relative clearfix sms-login hide">
... ...
{
"name": "yohobuy-node",
"version": "5.4.17",
"version": "5.4.18",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -55,7 +55,7 @@ var $accountInput1 = $('#account1'),
// 图像验证码
$captchaImgWrapper = $('.captcha-wrap'),
captchaImg = new Captcha('.captcha-wrap').init(),
$showCaptchaImg = false,
$showCaptchaImg = true,
getCaptchaImgVal = function() {
return captchaImg.getResults();
},
... ... @@ -278,7 +278,10 @@ accountChangeEvent.add(function(type) {
if (type === AccountLoginData.PasswordLogin.name) {
if ($showCaptchaImg) {
$captchaImgWrapper.removeClass('hide');
captchaImg.refresh();
setTimeout(function() {
captchaImg.refresh();
}, 500);
}
}
... ... @@ -848,7 +851,7 @@ function loginAsync() {
areaCode: getAreaCodeVal(),
account: currentLogin.getAccountVal(),
password: currentLogin.creditableToken(),
captcha: currentLogin.type() === 'password' ? getCaptchaImgVal() : '',
verifyCode: currentLogin.type() === 'password' ? getCaptchaImgVal() : '',
isRemember: getRememberMeVal(),
loginType: currentLogin.type()
}
... ...