...
|
...
|
@@ -24,26 +24,27 @@ |
|
|
|
|
|
return parseInt(now.getTime() / 1000, 10);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据输入的mobile获取area
|
|
|
* @param type $mobile
|
|
|
* @return int
|
|
|
*/
|
|
|
function handleMobile(mobile) {
|
|
|
let res = {};
|
|
|
|
|
|
//国际号
|
|
|
if (mobile.indexOf("-") > 0) {
|
|
|
let areaTmp = mobile.split("-");
|
|
|
|
|
|
res.area = areaTmp[0];
|
|
|
res.mobile = areaTmp[1];
|
|
|
}else {
|
|
|
res.area = 86;
|
|
|
res.mobile = mobile;
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
function handleMobile(mobile) {
|
|
|
let res = {};
|
|
|
|
|
|
// 国际号
|
|
|
if (mobile.indexOf('-') > 0) {
|
|
|
let areaTmp = mobile.split('-');
|
|
|
|
|
|
res.area = areaTmp[0];
|
|
|
res.mobile = areaTmp[1];
|
|
|
} else {
|
|
|
res.area = 86;
|
|
|
res.mobile = mobile;
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获得标题文案
|
...
|
...
|
@@ -581,15 +582,17 @@ |
|
|
* 个人中心-邮箱验证身份-邮件发送成功过渡页
|
|
|
*/
|
|
|
const sendEmailSuccess = (req, res, channel) => {
|
|
|
return co(function*() {
|
|
|
let checkType = req.body.checkType || 'userpwd',
|
|
|
email = req.body.email || '',
|
|
|
emailDomain = '',
|
|
|
type = req.body.email || 1;//1:身份验证 2:修改邮箱
|
|
|
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:修改邮箱
|
|
|
|
|
|
let headerData = yield headerModel.requestHeaderData(channel);
|
|
|
// 验证信息
|
|
|
let verifyInfo = yield auditCheckStatus(uid, 'mobile', step);
|
|
|
let headerData = yield headerModel.requestHeaderData(channel);
|
|
|
|
|
|
// 验证信息
|
|
|
let verifyInfo = yield auditCheckStatus(uid, checkType);
|
|
|
|
|
|
if (!verifyInfo.status) {
|
|
|
return {
|
...
|
...
|
@@ -597,7 +600,7 @@ |
|
|
meValidatePage: true
|
|
|
};
|
|
|
}
|
|
|
emailDomain = 'http://' + ((email.split[1] === 'gmail.com') ?
|
|
|
emailDomain = 'http://' + ((email.split[1] === 'gmail.com') ?
|
|
|
'mail.google.com' : 'mail.' + email.split[1]);
|
|
|
let data = {
|
|
|
subTitle: verifyInfo.subTitle,
|
...
|
...
|
@@ -616,321 +619,335 @@ |
|
|
],
|
|
|
returnInfo: true,
|
|
|
sendEmail: {
|
|
|
emailInfo: email.slice(0, 2) + '****' + email.slice(6),
|
|
|
emailUrl: emailDomain
|
|
|
emailInfo: email.slice(0, 2) + '****' + email.slice(6),
|
|
|
emailUrl: emailDomain
|
|
|
}
|
|
|
};
|
|
|
|
|
|
if (type === 1) {
|
|
|
data.progress[0].iscur = true;
|
|
|
}
|
|
|
else {
|
|
|
data.progress[1].iscur = true;
|
|
|
}
|
|
|
if (type === 1) {
|
|
|
data.progress[0].iscur = true;
|
|
|
} else {
|
|
|
data.progress[1].iscur = true;
|
|
|
}
|
|
|
|
|
|
let resqData = {meValidatePage: true};
|
|
|
let resqData = {meValidatePage: true};
|
|
|
|
|
|
resqData[verifyInfo.pageKey] = data;
|
|
|
return resqData;
|
|
|
resqData[verifyInfo.pageKey] = data;
|
|
|
return resqData;
|
|
|
|
|
|
})();
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 点击邮箱验证链接方法--修改验证邮箱
|
|
|
*/
|
|
|
const mailResult = (req, res) => {
|
|
|
return co(function*() {
|
|
|
let code = req.body.code;
|
|
|
return co(function*() {
|
|
|
let code = req.body.code;
|
|
|
|
|
|
let check = yield accountApi.checkEmailCode(code);
|
|
|
let check = yield accountApi.checkEmailCode(code);
|
|
|
|
|
|
if (check.code === 200) {
|
|
|
let data = yield accountApi.modifyVerifyEmail(code);
|
|
|
if (check.code === 200) {
|
|
|
let data = yield accountApi.modifyVerifyEmail(code);
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
res.redirect(helpers.urlFormat('/home/account/email',
|
|
|
{step: 3,success: true}));
|
|
|
}
|
|
|
}
|
|
|
if (data.code === 200) {
|
|
|
res.redirect(helpers.urlFormat('/home/account/email',
|
|
|
{step: 3, success: true}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
res.redirect(helpers.urlFormat('/home/account/email',
|
|
|
{step: 3,success: false}));
|
|
|
res.redirect(helpers.urlFormat('/home/account/email',
|
|
|
{step: 3, success: false}));
|
|
|
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
})();
|
|
|
};
|
|
|
/**
|
|
|
* 身份验证-登录密码验证Ajax
|
|
|
*/
|
|
|
const verifyPassword = (req) => {
|
|
|
return co(function*() {
|
|
|
let password = _.trim(req.body.password || ''),
|
|
|
uid = req.uid,
|
|
|
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase();
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message:'图形验证码不正确'
|
|
|
}
|
|
|
}
|
|
|
let data = yield accountApi.verifyPwd(uid, password);
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
let checkCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
|
|
|
const verifyPassword = (req) => {
|
|
|
return co(function*() {
|
|
|
let password = _.trim(req.body.password || ''),
|
|
|
uid = req.uid,
|
|
|
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase();
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '图形验证码不正确'
|
|
|
};
|
|
|
}
|
|
|
let data = yield accountApi.verifyPwd(uid, password);
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
|
|
|
'_' + password + captchaCode + 'completeverify');
|
|
|
|
|
|
data.data = checkCode;
|
|
|
}
|
|
|
return data;
|
|
|
})();
|
|
|
};
|
|
|
data.data = ckCode;
|
|
|
}
|
|
|
return data;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-验证密码正确性-ajax
|
|
|
*/
|
|
|
const checkPassword = (req) => {
|
|
|
return co(function*() {
|
|
|
let password = _.trim(req.body.password || ''),
|
|
|
uid = req.uid,
|
|
|
resqData = {code: 400};
|
|
|
return co(function*() {
|
|
|
let password = _.trim(req.body.password || ''),
|
|
|
uid = req.uid,
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
resqData = yield accountApi.verifyPwd(uid, password);
|
|
|
resqData = yield accountApi.verifyPwd(uid, password);
|
|
|
|
|
|
return resqData;
|
|
|
})();
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-验证图形验证码-ajax
|
|
|
*/
|
|
|
const checkVerifyCode = (req) => {
|
|
|
let captchaCode = _.trim(req.body.verifyCode || '').toLowerCase(),
|
|
|
resqData = {};
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
resqData.code = 400;
|
|
|
resqData.message = '图形验证码不正确';
|
|
|
}else {
|
|
|
resqData.code = code;
|
|
|
let captchaCode = _.trim(req.body.verifyCode || '').toLowerCase(),
|
|
|
resqData = {};
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
resqData.code = 400;
|
|
|
resqData.message = '图形验证码不正确';
|
|
|
} else {
|
|
|
resqData.code = 200;
|
|
|
resqData.message = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resqData;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 手机身份验证-校验手机号
|
|
|
*/
|
|
|
const identityMobile = (req) => {
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
resqData = {code: 400},
|
|
|
uid = req.uid,
|
|
|
check = false,
|
|
|
userId;
|
|
|
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
let userInfo = yield userApi.getUserInfoByMobile(area, mobile);
|
|
|
|
|
|
userId = 'uid' in userInfo.data ? userInfo.data.uid : 0;
|
|
|
if (userId === uid) {
|
|
|
check = true;
|
|
|
}
|
|
|
|
|
|
if (check) {
|
|
|
resqData = {
|
|
|
code: 200,
|
|
|
message: '',
|
|
|
data: ''
|
|
|
}
|
|
|
}else {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号错误',
|
|
|
data: ''
|
|
|
}
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
resqData = {code: 400},
|
|
|
uid = req.uid,
|
|
|
check = false,
|
|
|
userId;
|
|
|
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
let userInfo = yield userApi.getUserInfoByMobile(mobileInfo.area, mobile);
|
|
|
|
|
|
userId = 'uid' in userInfo.data ? userInfo.data.uid : 0;
|
|
|
if (userId === uid) {
|
|
|
check = true;
|
|
|
}
|
|
|
|
|
|
if (check) {
|
|
|
resqData = {
|
|
|
code: 200,
|
|
|
message: '',
|
|
|
data: ''
|
|
|
};
|
|
|
} else {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号错误',
|
|
|
data: ''
|
|
|
};
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 向验证手机号发送短信-ajax
|
|
|
*/
|
|
|
const sendMobileMsg = (req) => {
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
resqData = {code: 400},
|
|
|
uid = req.uid;
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
resqData = {code: 400},
|
|
|
uid = req.uid;
|
|
|
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
resqData = yield accountApi.sendMobileMsg(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
resqData = yield accountApi.sendMobileMsg(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
|
|
|
return resqData;
|
|
|
})();
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 校验短信验证码-ajax
|
|
|
*/
|
|
|
const checkMobileMsg = (req) => {
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
code = req.body.code || '',
|
|
|
uid = req.uid,
|
|
|
resqData;
|
|
|
|
|
|
if (mobile === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号为空',
|
|
|
data: ''
|
|
|
}
|
|
|
return resqData;
|
|
|
}
|
|
|
if (code === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '验证码为空',
|
|
|
data: ''
|
|
|
}
|
|
|
return resqData;
|
|
|
}
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
resqData = yield accountApi.checkVerifyMsg(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
|
|
|
if (resqData.code === 200) {
|
|
|
let checkCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) + '_' +
|
|
|
const checkMobileMsg = (req) => {
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
code = req.body.code || '',
|
|
|
uid = req.uid,
|
|
|
resqData;
|
|
|
|
|
|
if (mobile === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号为空',
|
|
|
data: ''
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
if (code === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '验证码为空',
|
|
|
data: ''
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
resqData = yield accountApi.checkVerifyMsg(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
|
|
|
if (resqData.code === 200) {
|
|
|
let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) + '_' +
|
|
|
mobileInfo.mobile + mobileInfo.area + 'completeverify');
|
|
|
|
|
|
resqData.data = checkCode;
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
resqData.data = ckCode;
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 身份验证时,发送邮件-ajax
|
|
|
*/
|
|
|
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拼接于邮箱域名处;
|
|
|
|
|
|
resqData = yield accountApi.sendVerifyEmailForNext(email, callback);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
const sendEmail = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
checkType = req.body.checkType || 'userpwd',
|
|
|
email = req.body.email || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
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) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
email = req.body.email || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
resqData = yield accountApi.checkVerifyEmail(uid, email);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
const checkEmail = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
email = req.body.email || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
resqData = yield accountApi.checkVerifyEmail(uid, email);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改密码
|
|
|
*/
|
|
|
const modifyPwd = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
newPwd = req.body.newPwd || '',
|
|
|
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase();
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
resqData.code = 400;
|
|
|
resqData.message = '图形验证码不正确';
|
|
|
}else {
|
|
|
resqData = yield accountApi.modifyPwd(uid, newPwd);
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
newPwd = req.body.newPwd || '',
|
|
|
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase(),
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
if (captchaCode && captchaCode !== req.session.captcha) {
|
|
|
resqData.code = 400;
|
|
|
resqData.message = '图形验证码不正确';
|
|
|
} else {
|
|
|
resqData = yield accountApi.modifyPwd(uid, newPwd);
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改验证手机号
|
|
|
*/
|
|
|
const modifyMobile = (req) => {
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
code = req.body.code || '',
|
|
|
uid = req.uid,
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
if (mobile === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号为空',
|
|
|
data: ''
|
|
|
}
|
|
|
return resqData;
|
|
|
}
|
|
|
if (code === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '验证码为空',
|
|
|
data: ''
|
|
|
}
|
|
|
return resqData;
|
|
|
}
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
let checkFlag = accountApi.checkVerifyMobile(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
|
|
|
if (checkFlag.code === 200) {
|
|
|
resqData = accountApi.modifyVerifyMobile(uid, mobileInfo.area, mobileInfo.mobile);
|
|
|
}else {
|
|
|
resqData = {
|
|
|
code: checkFlag.data,
|
|
|
message: checkFlag.message,
|
|
|
data: ''
|
|
|
}
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
return co(function*() {
|
|
|
let mobile = req.body.mobile || '',
|
|
|
code = req.body.code || '',
|
|
|
uid = req.uid,
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
if (mobile === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '手机号为空',
|
|
|
data: ''
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
if (code === '') {
|
|
|
resqData = {
|
|
|
code: 400,
|
|
|
message: '验证码为空',
|
|
|
data: ''
|
|
|
};
|
|
|
return resqData;
|
|
|
}
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
let checkFlag = accountApi.checkVerifyMobile(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
|
|
|
if (checkFlag.code === 200) {
|
|
|
resqData = accountApi.modifyVerifyMobile(uid, mobileInfo.area, mobileInfo.mobile);
|
|
|
} else {
|
|
|
resqData = {
|
|
|
code: checkFlag.data,
|
|
|
message: checkFlag.message,
|
|
|
data: ''
|
|
|
};
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 分-检查手机号是否可修改-ajax
|
|
|
*/
|
|
|
const checkMobile = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
mobile = req.body.mobile || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
resqData = yield accountApi.checkVerifyMobile(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
const checkMobile = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
mobile = req.body.mobile || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
let mobileInfo = handleMobile(mobile);
|
|
|
|
|
|
resqData = yield accountApi.checkVerifyMobile(uid, mobileInfo.mobile, mobileInfo.area);
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改验证邮箱校验并发送邮件-ajax
|
|
|
*
|
|
|
*
|
|
|
*/
|
|
|
const modifyEmail = (req) => {
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
email = req.body.email || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
let check = yield accountApi.checkVerifyEmail(uid, email);
|
|
|
|
|
|
if (check.code === 200) {
|
|
|
resqData = accountApi.sendVerifyEmail(uid, email);
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
return co(function*() {
|
|
|
let uid = req.body.uid,
|
|
|
email = req.body.email || '',
|
|
|
resqData = {code: 400};
|
|
|
|
|
|
let check = yield accountApi.checkVerifyEmail(uid, email);
|
|
|
|
|
|
if (check.code === 200) {
|
|
|
resqData = accountApi.sendVerifyEmail(uid, email);
|
|
|
}
|
|
|
return resqData;
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getAccountInfo,
|
|
|
userPwd,
|
...
|
...
|
|