Authored by 毕凯

增加注册验证码

... ... @@ -78,20 +78,19 @@ let checkMobile = (req, res, next) => {
}).catch(next);
};
let picCaptcha = (req, res, next) => {
let picCaptcha = (req, res) => {
let verifyCode = _.trim(req.body.verifyCode);
let picFlag = true; // TODO: 图形验证码校验
if (picFlag) {
if (verifyCode !== req.session.captcha) {
return res.json({
code: 200,
message: '验证码正确'
code: 400,
message: '验证码错误'
});
}
return res.json({
code: 400,
message: '验证码错误'
code: 200,
message: '验证码正确'
});
};
... ... @@ -104,7 +103,6 @@ let sendBindMsg = (req, res, next) => {
let mobile = +req.body.mobile;
let area = +req.body.area;
let verifyCode = +req.body.verifyCode;
// 判断参数是否合法
if (!_.isNumber(mobile) || !_.isNumber(area)) {
... ... @@ -112,6 +110,13 @@ let sendBindMsg = (req, res, next) => {
return res.json(data);
}
let verifyCode = _.trim(req.body.verifyCode);
if (verifyCode !== req.session.captcha) {
data.message = '验证码不正确';
return res.json(data);
}
// 检查是否检查过
// let makeMobile = passportHelper.makeAreaMobile(area, mobile);
//
... ... @@ -140,13 +145,6 @@ let sendBindMsg = (req, res, next) => {
return res.json(data);
}
// TODO: 检测验证码不正确
// if (!PassportModel::verifyCode($verifyCode)) {
// $data['code'] = 400;
// $data['message'] = '图形验证码不正确';
// break;
// }
/* 向手机发送注册验证码 */
return regService.sendCodeToMobile(area, mobile).then((result) => {
return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => {
... ... @@ -212,12 +210,12 @@ let mobileRegister = (req, res, next) => {
return res.json(data);
}
// TODO: 检测验证码不正确
// $verifyCode = strtolower(trim($this->post('verifyCode'))); //图形验证码
// if (!PassportModel::verifyCode($verifyCode)) {
// $data['message'] = '验证码不正确';
// break;
// }
let verifyCode = _.trim(req.body.verifyCode);
if (verifyCode !== req.session.captcha) {
data.message = '验证码不正确';
return res.json(data);
}
/* 判断密码是否符合规则 */
let code = +req.body.code; // 短信验证码
... ...
... ... @@ -33,6 +33,7 @@
"dependencies": {
"bluebird": "^3.4.0",
"body-parser": "^1.15.0",
"captchapng": "0.0.1",
"connect-memcached": "^0.2.0",
"cookie-parser": "^1.4.3",
"express": "^4.13.1",
... ...