Authored by shijian

多处验证码可以重复使用 bug修改

... ... @@ -82,6 +82,15 @@ const getUserInfoAPI = (req, res, next) => {
const sendCodePage = (req, res, next) => {
let inputInfo = req.inputInfo;
if (req.session.mobile && req.session.mobile !== inputInfo.phone) {
req.session.mobile = '';
req.session.captcha = '';
return res.json({
code: 400,
message: '验证码失效',
data: ''
});
}
BackService.sendCodeToUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
.then(result => {
if (!(result.code && result.code === 200)) {
... ... @@ -122,8 +131,8 @@ const sendBackMobileAPI = (req, res, next) => {
let area = req.body.area || '86';
// 检查上次的发送短信号码
if (req.session.sendMobile && req.session.sendMobile !== mobile) {
req.session.sendMobile = '';
if (req.session.mobile && req.session.mobile !== mobile) {
req.session.mobile = '';
req.session.captcha = '';
return res.json({
code: 400,
... ... @@ -135,7 +144,7 @@ const sendBackMobileAPI = (req, res, next) => {
BackService.sendCodeToMobileAsync(area, mobile)
.then(result => {
// 记录发送短信的号码
req.session.sendMobile = mobile;
req.session.mobile = mobile;
res.json(result);
})
.catch(next);
... ...
... ... @@ -253,6 +253,7 @@ const local = {
LoginService.sendPasswordBySMS(area, mobile).then((result) => {
if (result && result.code === 200) {
req.session.captcha = '';
req.session.sendMobile = mobile;
}
... ...
... ... @@ -55,7 +55,7 @@ passport.use('local', new LocalStrategy({
let verifyCode = req.body.captcha;
if (verifyCode && verifyCode !== req.session.captcha) {
if (type !== 'SMSLogin' && verifyCode && verifyCode !== req.session.captcha) {
return done({message: '验证码不正确或验证码过期', needCaptcha: true}, null);
}
... ...
... ... @@ -735,7 +735,7 @@ function loginAsync() {
// 全部的本地验证-- 短信验证登录
function smsLoginAsync() {
return validateAccount()
.then(validateCaptchaImg)
//.then(validateCaptchaImg)
.then(validateCaptchaSms)
.then(function() {
return login();
... ...