Authored by 毕凯

升价依赖

... ... @@ -13,6 +13,9 @@ let helpers = global.yoho.helpers;
let cache = global.yoho.cache;
let cookie = global.yoho.cookie;
/**
* 注册首页
*/
let index = (req, res, next) => {
// 设置注册有效时间30分钟, 防机器刷
req.session._REG_EXPIRE = Date.now() + 1800000;
... ... @@ -41,6 +44,9 @@ let index = (req, res, next) => {
}).catch(next);
};
/**
* 检查手机号码是否注册过
*/
let checkMobile = (req, res, next) => {
let data = {
code: 400
... ... @@ -54,30 +60,33 @@ let checkMobile = (req, res, next) => {
}
// 判断手机号是否检查超过指定次数
let key = 'checkmobilenum_' + passportHelper.makeAreaMobile(area, mobile);
let regCheckKey = 'regCheckMobileNum_' + passportHelper.makeAreaMobile(area, mobile);
let checkNum = req.session[regCheckKey];
cache.get(key).then((checkNum) => {
checkNum = +(checkNum || 0);
checkNum = +(checkNum || 0);
req.session[regCheckKey] = ++checkNum;
cache.set(key, ++checkNum).catch(next);
if (checkNum > 500) {
data.message = '检查次数太多';
return res.json(data);
}
if (checkNum > 500) {
data.message = '检查次数太多';
return res.json(data);
}
// 判断用户是否存在
return userService.findByMobileAsync(area, mobile).then((user) => {
if (!_.isEmpty(user)) {
data.message = '手机号码已经存在';
return res.json(data);
}
data.code = 200;
// 判断用户是否存在
return userService.findByMobileAsync(area, mobile).then((user) => {
if (!_.isEmpty(user)) {
data.message = '手机号码已经存在';
return res.json(data);
});
}
data.code = 200;
return res.json(data);
}).catch(next);
};
/**
* 图形验证码校验
*/
let picCaptcha = (req, res) => {
let verifyCode = _.trim(req.body.verifyCode);
... ... @@ -94,6 +103,9 @@ let picCaptcha = (req, res) => {
});
};
/**
* 发送验证码
*/
let sendBindMsg = (req, res, next) => {
let data = {
code: 400,
... ... @@ -118,12 +130,13 @@ let sendBindMsg = (req, res, next) => {
}
// 检查是否检查过
// let makeMobile = passportHelper.makeAreaMobile(area, mobile);
//
// if (req.session[`checkmobile_${makeMobile}`] !== makeMobile) {
// data.message = '发送失败';
// return res.json(data);
// }
let regCheckKey = 'regCheckMobileNum_' + passportHelper.makeAreaMobile(area, mobile);
let checkNum = req.session[regCheckKey];
if (!checkNum) {
data.message = '发送失败';
return res.json(data);
}
// 校验是否发送过多
let sendCodeKey = `send_code_${area}_${mobile}`;
... ... @@ -159,6 +172,9 @@ let sendBindMsg = (req, res, next) => {
}).catch(next);
};
/**
* 短信验证码校验
*/
let msgCaptcha = (req, res, next) => {
let data = {
code: 400,
... ... @@ -186,6 +202,9 @@ let msgCaptcha = (req, res, next) => {
}).catch(next);
};
/**
* 注册接口
*/
let mobileRegister = (req, res, next) => {
let data = {
code: 400,
... ...
... ... @@ -59,7 +59,7 @@
"uuid": "^2.0.2",
"winston": "^2.2.0",
"winston-daily-rotate-file": "^1.1.4",
"yoho-node-lib": "0.0.7"
"yoho-node-lib": "0.0.11"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
... ... @@ -83,7 +83,7 @@
"postcss-center": "^1.0.0",
"postcss-clearfix": "^1.0.0",
"postcss-crip": "^2.0.0",
"postcss-opacity": "^3.0.0",
"postcss-opacity": "^4.0.0",
"postcss-position": "^0.5.0",
"postcss-pxtorem": "^3.3.1",
"postcss-short": "^1.4.0",
... ... @@ -92,7 +92,7 @@
"precss": "^1.4.0",
"rewire": "^2.5.1",
"shelljs": "^0.7.0",
"stylelint": "^6.6.0",
"stylelint": "^6.8.0",
"stylelint-config-yoho": "^1.2.4",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1",
... ... @@ -100,7 +100,7 @@
"yoho-handlebars": "^4.0.5",
"yoho-jquery": "^1.12.4",
"yoho-jquery-lazyload": "^1.9.7",
"yoho-jquery-placeholder": "0.0.3",
"yoho-jquery-placeholder": "^2.3.1",
"yoho-slider": "0.0.2"
}
}
... ...