...
|
...
|
@@ -24,6 +24,7 @@ |
|
|
|
|
|
return parseInt(now.getTime() / 1000, 10);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据输入的mobile获取area
|
|
|
* @param type $mobile
|
...
|
...
|
@@ -32,13 +33,13 @@ |
|
|
function handleMobile(mobile) {
|
|
|
let res = {};
|
|
|
|
|
|
//国际号
|
|
|
if (mobile.indexOf("-") > 0) {
|
|
|
let areaTmp = mobile.split("-");
|
|
|
// 国际号
|
|
|
if (mobile.indexOf('-') > 0) {
|
|
|
let areaTmp = mobile.split('-');
|
|
|
|
|
|
res.area = areaTmp[0];
|
|
|
res.mobile = areaTmp[1];
|
|
|
}else {
|
|
|
} else {
|
|
|
res.area = 86;
|
|
|
res.mobile = mobile;
|
|
|
}
|
...
|
...
|
@@ -583,13 +584,15 @@ |
|
|
const sendEmailSuccess = (req, res, channel) => {
|
|
|
return co(function*() {
|
|
|
let checkType = req.body.checkType || 'userpwd',
|
|
|
uid = req.body.uid,
|
|
|
email = req.body.email || '',
|
|
|
emailDomain = '',
|
|
|
type = req.body.email || 1;//1:身份验证 2:修改邮箱
|
|
|
type = req.body.email || 1;// 1:身份验证 2:修改邮箱
|
|
|
|
|
|
let headerData = yield headerModel.requestHeaderData(channel);
|
|
|
|
|
|
// 验证信息
|
|
|
let verifyInfo = yield auditCheckStatus(uid, 'mobile', step);
|
|
|
let verifyInfo = yield auditCheckStatus(uid, checkType);
|
|
|
|
|
|
if (!verifyInfo.status) {
|
|
|
return {
|
...
|
...
|
@@ -623,8 +626,7 @@ |
|
|
|
|
|
if (type === 1) {
|
|
|
data.progress[0].iscur = true;
|
|
|
}
|
|
|
else {
|
|
|
} else {
|
|
|
data.progress[1].iscur = true;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -635,6 +637,7 @@ |
|
|
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 点击邮箱验证链接方法--修改验证邮箱
|
|
|
*/
|
...
|
...
|
@@ -649,19 +652,20 @@ |
|
|
|
|
|
if (data.code === 200) {
|
|
|
res.redirect(helpers.urlFormat('/home/account/email',
|
|
|
{step: 3,success: true}));
|
|
|
{step: 3, success: true}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
res.redirect(helpers.urlFormat('/home/account/email',
|
|
|
{step: 3,success: false}));
|
|
|
{step: 3, success: false}));
|
|
|
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 身份验证-登录密码验证Ajax
|
|
|
*/
|
|
|
const verifyPassword = (req) => {
|
|
|
const verifyPassword = (req) => {
|
|
|
return co(function*() {
|
|
|
let password = _.trim(req.body.password || ''),
|
|
|
uid = req.uid,
|
...
|
...
|
@@ -670,20 +674,21 @@ const verifyPassword = (req) => { |
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message:'图形验证码不正确'
|
|
|
}
|
|
|
message: '图形验证码不正确'
|
|
|
};
|
|
|
}
|
|
|
let data = yield accountApi.verifyPwd(uid, password);
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
let checkCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
|
|
|
if (data.code === 200) {
|
|
|
let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
|
|
|
'_' + password + captchaCode + 'completeverify');
|
|
|
|
|
|
data.data = checkCode;
|
|
|
data.data = ckCode;
|
|
|
}
|
|
|
return data;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-验证密码正确性-ajax
|
|
|
*/
|
...
|
...
|
@@ -698,6 +703,7 @@ const verifyPassword = (req) => { |
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-验证图形验证码-ajax
|
|
|
*/
|
...
|
...
|
@@ -708,13 +714,14 @@ const verifyPassword = (req) => { |
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
resqData.code = 400;
|
|
|
resqData.message = '图形验证码不正确';
|
|
|
}else {
|
|
|
resqData.code = code;
|
|
|
} else {
|
|
|
resqData.code = 200;
|
|
|
resqData.message = '';
|
|
|
}
|
|
|
|
|
|
return resqData;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 手机身份验证-校验手机号
|
|
|
*/
|
...
|
...
|
@@ -728,7 +735,7 @@ const verifyPassword = (req) => { |
|
|
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
let userInfo = yield userApi.getUserInfoByMobile(area, mobile);
|
|
|
let userInfo = yield userApi.getUserInfoByMobile(mobileInfo.area, mobile);
|
|
|
|
|
|
userId = 'uid' in userInfo.data ? userInfo.data.uid : 0;
|
|
|
if (userId === uid) {
|
...
|
...
|
@@ -740,17 +747,18 @@ const verifyPassword = (req) => { |
|
|
code: 200,
|
|
|
message: '',
|
|
|
data: ''
|
|
|
}
|
|
|
}else {
|
|
|
};
|
|
|
} else {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号错误',
|
|
|
data: ''
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 向验证手机号发送短信-ajax
|
|
|
*/
|
...
|
...
|
@@ -767,10 +775,11 @@ const verifyPassword = (req) => { |
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 校验短信验证码-ajax
|
|
|
*/
|
|
|
const checkMobileMsg = (req) => {
|
|
|
const checkMobileMsg = (req) => {
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
code = req.body.code || '',
|
...
|
...
|
@@ -782,7 +791,7 @@ const checkMobileMsg = (req) => { |
|
|
code: 400,
|
|
|
message: '手机号为空',
|
|
|
data: ''
|
|
|
}
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
if (code === '') {
|
...
|
...
|
@@ -790,7 +799,7 @@ const checkMobileMsg = (req) => { |
|
|
code: 400,
|
|
|
message: '验证码为空',
|
|
|
data: ''
|
|
|
}
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
let mobileInfo = handleMobile(mobile);
|
...
|
...
|
@@ -798,36 +807,39 @@ const checkMobileMsg = (req) => { |
|
|
resqData = yield accountApi.checkVerifyMsg(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
|
|
|
if (resqData.code === 200) {
|
|
|
let checkCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) + '_' +
|
|
|
let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) + '_' +
|
|
|
mobileInfo.mobile + mobileInfo.area + 'completeverify');
|
|
|
|
|
|
resqData.data = checkCode;
|
|
|
resqData.data = ckCode;
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 身份验证时,发送邮件-ajax
|
|
|
*/
|
|
|
const sendEmail = (req) => {
|
|
|
const sendEmail = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
checkType = req.body.checkType || 'userpwd',
|
|
|
email = req.body.email || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
let checkCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
|
|
|
'_' + email + checkType + 'completeverify'),
|
|
|
callback = 'home/account/' + checkType + '?step=2&checkCode=' + checkCode; //callback拼接于邮箱域名处;
|
|
|
let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
|
|
|
'_' + email + checkType + 'completeverify');
|
|
|
|
|
|
let callback = 'home/account/' + checkType + '?step=2&checkCode=' + ckCode; // callback拼接于邮箱域名处;
|
|
|
|
|
|
resqData = yield accountApi.sendVerifyEmailForNext(email, callback);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-修改邮箱前,校验邮箱-ajax
|
|
|
*/
|
|
|
const checkEmail = (req) => {
|
|
|
const checkEmail = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
email = req.body.email || '',
|
...
|
...
|
@@ -836,7 +848,8 @@ const checkEmail = (req) => { |
|
|
resqData = yield accountApi.checkVerifyEmail(uid, email);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改密码
|
|
|
*/
|
...
|
...
|
@@ -844,18 +857,19 @@ const checkEmail = (req) => { |
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
newPwd = req.body.newPwd || '',
|
|
|
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase();
|
|
|
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase(),
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
resqData.code = 400;
|
|
|
resqData.message = '图形验证码不正确';
|
|
|
}else {
|
|
|
} else {
|
|
|
resqData = yield accountApi.modifyPwd(uid, newPwd);
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改验证手机号
|
|
|
*/
|
...
|
...
|
@@ -871,7 +885,7 @@ const checkEmail = (req) => { |
|
|
code: 400,
|
|
|
message: '手机号为空',
|
|
|
data: ''
|
|
|
}
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
if (code === '') {
|
...
|
...
|
@@ -879,7 +893,7 @@ const checkEmail = (req) => { |
|
|
code: 400,
|
|
|
message: '验证码为空',
|
|
|
data: ''
|
|
|
}
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
let mobileInfo = handleMobile(mobile);
|
...
|
...
|
@@ -888,20 +902,21 @@ const checkEmail = (req) => { |
|
|
|
|
|
if (checkFlag.code === 200) {
|
|
|
resqData = accountApi.modifyVerifyMobile(uid, mobileInfo.area, mobileInfo.mobile);
|
|
|
}else {
|
|
|
} else {
|
|
|
resqData = {
|
|
|
code: checkFlag.data,
|
|
|
message: checkFlag.message,
|
|
|
data: ''
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-检查手机号是否可修改-ajax
|
|
|
*/
|
|
|
const checkMobile = (req) => {
|
|
|
const checkMobile = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
mobile = req.body.mobile || '',
|
...
|
...
|
@@ -912,7 +927,8 @@ const checkMobile = (req) => { |
|
|
resqData = yield accountApi.checkVerifyMobile(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改验证邮箱校验并发送邮件-ajax
|
|
|
*
|
...
|
...
|
@@ -930,7 +946,8 @@ const checkMobile = (req) => { |
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getAccountInfo,
|
|
|
userPwd,
|
...
|
...
|
|