Authored by 陈轩

Merge branch 'hotfix/register' into release/5.2

... ... @@ -242,6 +242,7 @@ let sendCode = (req, res, next) => {
}
}).catch(next);
};
let verifyCode = (req, res, next) => {
let data = {
code: 400,
... ... @@ -298,20 +299,19 @@ let verifyCode = (req, res, next) => {
/**
* Step3: set Password
*/
let passwordAction = (req, res) => {
let passwordAction = (req, res, next) => {
let token = req.query.token;
let mobile = +req.query.phoneNum;
let area = +(req.query.areaCode || 86);
let smsCode = +req.query.smsCode;
// 判断是否允许访问, 不允许则跳转到错误页面
// if (!smsCode || !_.isString(token) || !_.isNumber(mobile) || !_.isNumber(area) || !sign.verifyToken(mobile, token)) {
// return next({
// code: 403,
// message: 'error token, mobile or verifyCode'
// });
// }
if (!smsCode || !_.isString(token) || !_.isNumber(mobile) || !_.isNumber(area) || !sign.verifyToken(mobile, token)) {
return next({
code: 403,
message: 'error token, mobile or verifyCode'
});
}
res.render('reg/password', {
page: 'password',
... ...
... ... @@ -44,7 +44,7 @@ if (qs.selected && qs.selected === 'N') {
$('.pitch').removeClass('select').html('');
}
if(qs.pwd) {
if (qs.pwd) {
$pwd.val(qs.pwd);
if (trim($pwd.val()) === '') {
... ... @@ -64,6 +64,31 @@ $('.pitch').on('click', function() {
}
});
function setPassword() {
return $.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: trim($pwd.val()),
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
smsCode: $('#sms-code').val(),
token: $('#token').val()
},
success: function(data) {
var res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
location.href = res.href;
} else {
showErrTip(data.message);
}
}
});
}
$btnSure.on('touchstart', function() {
var pwd = trim($pwd.val());
... ... @@ -74,30 +99,8 @@ $btnSure.on('touchstart', function() {
if (!validatePWD(pwd)) {
showErrTip('密码6-20位,请重新输入');
} else {
if ($('.pitch').hasClass('select')) {
$.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: pwd,
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
smsCode: $('#sms-code').val(),
token: $('#token').val()
},
success: function(data) {
var res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
location.href = res.href;
} else {
showErrTip(data.message);
}
}
});
setPassword();
} else {
$('.prompt').show();
... ... @@ -106,27 +109,7 @@ $btnSure.on('touchstart', function() {
$('.pitch').addClass('select');
$('.pitch').html('');
$.ajax({
type: 'POST',
url: '/passport/reg/setpassword',
data: {
password: pwd,
phoneNum: $('#phone-num').val(),
areaCode: $('#area-code').val(),
token: $('#token').val()
},
success: function(data) {
var res = data.data;
if (data.code === 200) {
showErrTip('注册成功');
location.href = res.href;
} else {
showErrTip(data.message);
}
}
});
setPassword();
});
$('.deny').on('click', function() {
... ...