Merge branch 'feature/captchapng' into release/5.2
Showing
1 changed file
with
14 additions
and
1 deletions
@@ -95,8 +95,21 @@ let verifyMobile = (req, res, next) => { | @@ -95,8 +95,21 @@ let verifyMobile = (req, res, next) => { | ||
95 | let mobile = +req.body.phoneNum; | 95 | let mobile = +req.body.phoneNum; |
96 | let area = +(req.body.areaCode || 86); | 96 | let area = +(req.body.areaCode || 86); |
97 | let captcha = (req.body.captcha || '').trim(); | 97 | let captcha = (req.body.captcha || '').trim(); |
98 | + let diffCaptcha = _.get(req.session, 'phoneReg.captcha'); | ||
98 | 99 | ||
99 | - if (captcha !== _.get(req.session, 'phoneReg.captcha')) { | 100 | + // error case: 没有验证码 |
101 | + if (!diffCaptcha) { | ||
102 | + return res.json({ | ||
103 | + code: 400, | ||
104 | + message: '请求失败', | ||
105 | + refreshCaptcha: true | ||
106 | + }); | ||
107 | + } | ||
108 | + | ||
109 | + delete req.session.phoneReg.captcha; // captcha 一次性 | ||
110 | + | ||
111 | + // error case: 验证码不匹配 | ||
112 | + if (captcha !== diffCaptcha) { | ||
100 | return res.json({ | 113 | return res.json({ |
101 | code: 400, | 114 | code: 400, |
102 | message: '校验码不正确', | 115 | message: '校验码不正确', |
-
Please register or login to post a comment