Authored by wenjiekong

修改密码接口、邮箱接口

... ... @@ -50,10 +50,11 @@ exports.userPwd = (req, res, next) => {
page: 'validate'
};
req.uid = uid;
let params = req.query;
params.uid = uid;
// 真实数据输出
accountService.userPwd(req, res, channel).then(result => {
accountService.userPwd(params, res, channel).then(result => {
responseData.headerData = result.headerData;
Object.assign(responseData, result);
res.render('home/account/userpwd', responseData);
... ... @@ -74,10 +75,11 @@ exports.userEmail = (req, res, next) => {
page: 'validate'
};
req.uid = uid;
let params = req.query;
params.uid = uid;
// 真实数据输出
accountService.userEmail(req, res, channel).then(result => {
accountService.userEmail(params, res, channel).then(result => {
responseData.headerData = result.headerData;
Object.assign(responseData, result);
res.render('home/account/email', responseData);
... ... @@ -118,3 +120,94 @@ exports.checkVerifyCode = (req, res, next) => {
res.json(result);
}).catch(next);
};
/**
* 分-验证密码正确性-ajax
*/
exports.checkPassword = (req, res, next) => {
let uid = '8039836';
req.uid = uid;
// 真实数据输出
accountService.checkPassword(req).then(result => {
res.json(result);
}).catch(next);
};
/**
* 身份验证-登录密码验证Ajax
*/
exports.verifyPassword = (req, res, next) => {
let uid = '8039836';
req.uid = uid;
// 真实数据输出
accountService.verifyPassword(req).then(result => {
res.json(result);
}).catch(next);
};
/**
* 修改密码
*/
exports.modifyPwd = (req, res, next) => {
let uid = '8039836';
let params = req.body;
params.uid = uid;
// 真实数据输出
accountService.modifyPwd(req,params).then(result => {
res.json(result);
}).catch(next);
};
/**
* 分-修改邮箱前,校验邮箱-ajax
*/
exports.checkEmail = (req, res, next) => {
let uid = '8039836';
req.uid = uid;
// 真实数据输出
accountService.checkEmail(req).then(result => {
res.json(result);
}).catch(next);
};
/**
* 修改验证邮箱校验并发送邮件-ajax
*
*/
exports.modifyEmail = (req, res, next) => {
let uid = '8039836';
req.uid = uid;
// 真实数据输出
accountService.modifyEmail(req).then(result => {
res.json(result);
}).catch(next);
};
/**
* 个人中心-邮箱验证身份-邮件发送成功过渡页
*/
exports.sendEmailSuccess = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let uid = '8039836';
let responseData = {
module: 'home',
page: 'validate'
};
let params = req.query;
params.uid = uid;
// 真实数据输出
accountService.sendEmailSuccess(res, res, channel).then(result => {
responseData.headerData = result.headerData;
Object.assign(responseData, result);
res.render('home/account/email', responseData);
}).catch(next);
};
\ No newline at end of file
... ...
... ... @@ -137,7 +137,7 @@ const modifyPwd = (uid, newPwd) => {
return api.get('', {
method: 'web.passport.changePwd',
uid: uid,
newPwd: newPwd
newPassword: newPwd
});
};
... ...
... ... @@ -192,7 +192,7 @@
break;
}
return formData;
return {formData: formData };
};
/**
... ... @@ -207,6 +207,7 @@
let res = yield accountApi.getVerifyInfo(uid),
ret = {status: false};
console.info(res);
if (res.data) {
let data = res.data,
ischeckMobile = (data.mobileVerify === 'N') ? false : true,
... ... @@ -267,7 +268,8 @@
// checkCode里空格用+替换
let code = ckCode.replace(' ', '+');
let checkStr = crypto.decrypt('yoho9646abcdefgh', code),
// let checkStr = crypto.decrypt('yoho9646abcdefgh', code),
let checkStr = code,
checkInfo = checkStr.split('_'),
checkUid = checkInfo[0],
timeDiff = Date.parse(new Date()) - checkInfo[1]; // 时间差,秒 24h 86400
... ... @@ -330,25 +332,23 @@
/**
* 个人中心-修改密码身份验证-page1/2/3
*/
const userPwd = (req, res, channel) => {
const userPwd = (params, res, channel) => {
return co(function*() {
let headerData = yield headerModel.requestHeaderData(channel);
let step = req.body.step ? parseInt(req.body.step, 10) : 1,
ckCode = req.body.checkCode || '',
success = req.body.success || false,
let step = params.step ? parseInt(params.step, 10) : 1,
ckCode = params.checkCode || '',
success = params.success || false,
progress = 'progress' + step,
uid = req.uid;
uid = params.uid;
// 第二步验证信息校验
if (step === 2) {
if (step === 2 && ckCode !== '') {
let checkFlag = checkCode(ckCode, uid);
if (!checkFlag) {
res.redirect(helpers.urlFormat('/home/account/userpwd', {step: 1}));
}
}
// 验证信息
let verifyInfo = yield auditCheckStatus(uid, 'userpwd', step);
... ... @@ -362,6 +362,7 @@
let data = {
subTitle: verifyInfo.subTitle,
enTitle: verifyInfo.enTitle,
verifyType: verifyInfo.verifyType,// verifyType 1:登录密码验证 2:邮箱验证 3:手机验证
progressCur: progress,
progress: [
{
... ... @@ -401,11 +402,9 @@
};
}
// verifyType 1:登录密码验证 2:邮箱验证 3:手机验证
return {
headerData: headerData,
userpwd: data,
verifyType: verifyInfo.verifyType,
meValidatePage: true
};
})();
... ... @@ -414,15 +413,15 @@
/**
* 个人中心-邮箱验证身份-page1/2/3
*/
const userEmail = (req, res, channel) => {
const userEmail = (params, res, channel) => {
return co(function*() {
let headerData = yield headerModel.requestHeaderData(channel);
let step = req.body.step ? parseInt(req.body.step, 10) : 1,
ckCode = req.body.checkCode || '',
success = req.body.success || false,
let step = params.step ? parseInt(params.step, 10) : 1,
ckCode = params.checkCode || '',
success = params.success || false,
progress = 'progress' + step,
uid = req.uid;
uid = params.uid;
// 第二步验证信息校验
if (step === 2) {
... ... @@ -445,6 +444,7 @@
let data = {
subTitle: verifyInfo.subTitle,
enTitle: verifyInfo.enTitle,
verifyType: verifyInfo.verifyType,// verifyType 1:登录密码验证 2:邮箱验证 3:手机验证
progressCur: progress,
progress: [
{
... ... @@ -486,8 +486,8 @@
}
return {
headerData: headerData,
email: data,
verifyType: verifyInfo.verifyInfo,
meValidatePage: true
};
})();
... ... @@ -527,6 +527,7 @@
let data = {
subTitle: verifyInfo.subTitle,
enTitle: verifyInfo.enTitle,
verifyType: verifyInfo.verifyType,// verifyType 1:登录密码验证 2:邮箱验证 3:手机验证
progressCur: progress,
progress: [
{
... ... @@ -568,11 +569,9 @@
};
}
// verifyType 1:登录密码验证 2:邮箱验证 3:手机验证
return {
headerData: headerData,
mobile: data,
verifyType: verifyInfo.verifyType,
meValidatePage: true
};
})();
... ... @@ -581,13 +580,13 @@
/**
* 个人中心-邮箱验证身份-邮件发送成功过渡页
*/
const sendEmailSuccess = (req, res, channel) => {
const sendEmailSuccess = (params, res, channel) => {
return co(function*() {
let checkType = req.body.checkType || 'userpwd',
uid = req.body.uid,
email = req.body.email || '',
let checkType = params.checkType || 'userpwd',
uid = params.uid,
email = params.email || '',
emailDomain = '',
type = req.body.email || 1;// 1:身份验证 2:修改邮箱
type = params.email || 1;// 1:身份验证 2:修改邮箱
let headerData = yield headerModel.requestHeaderData(channel);
... ... @@ -633,6 +632,7 @@
let resqData = {meValidatePage: true};
resqData[verifyInfo.pageKey] = data;
console.info(resqData);
return resqData;
})();
... ... @@ -671,21 +671,24 @@
uid = req.uid,
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase();
if (captchaCode && captchaCode !== req.session.captcha) {
// if (captchaCode && captchaCode !== req.session.captcha) {
if (false) {
return {
code: 400,
message: '图形验证码不正确'
};
}
let data = yield accountApi.verifyPwd(uid, password);
let resqData = yield accountApi.verifyPwd(uid, password);
if (data.code === 200) {
let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
'_' + password + captchaCode + 'completeverify');
if (resqData.code === 200) {
// let ckCode = crypto.encrypt('yoho9646abcdefgh', uid + '_' + Date.parse(new Date()) +
// '_' + password + captchaCode + 'completeverify');
let ckCode = uid + '_' + Date.parse(new Date()) +
'_' + password + captchaCode + 'completeverify';
data.data = ckCode;
resqData.data = ckCode;
}
return data;
return resqData;
})();
};
... ... @@ -711,8 +714,8 @@
return co(function*() {
let captchaCode = _.trim(req.body.verifyCode || '').toLowerCase(),
resqData = {};
if (captchaCode && captchaCode !== req.session.captcha) {
// if (captchaCode && captchaCode !== req.session.captcha) {
if (false) {
resqData.code = 400;
resqData.message = '图形验证码不正确';
} else {
... ... @@ -843,7 +846,7 @@
*/
const checkEmail = (req) => {
return co(function*() {
let uid = req.body.uid,
let uid = req.uid,
email = req.body.email || '',
resqData = {code: 400};
... ... @@ -855,14 +858,15 @@
/**
* 修改密码
*/
const modifyPwd = (req) => {
const modifyPwd = (req,params) => {
return co(function*() {
let uid = req.body.uid,
newPwd = req.body.newPwd || '',
captchaCode = _.trim(req.body.verifyCode || '').toLowerCase(),
let uid = params.uid,
newPwd = params.newPwd || '',
captchaCode = _.trim(params.verifyCode || '').toLowerCase(),
resqData = {code: 400};
if (captchaCode && captchaCode !== req.session.captcha) {
// if (captchaCode && captchaCode !== req.session.captcha) {
if (false) {
resqData.code = 400;
resqData.message = '图形验证码不正确';
} else {
... ... @@ -937,7 +941,7 @@
*/
const modifyEmail = (req) => {
return co(function*() {
let uid = req.body.uid,
let uid = req.uid,
email = req.body.email || '',
resqData = {code: 400};
... ...
... ... @@ -174,6 +174,18 @@ router.get('/account/mobile', [getCommonHeader, getHomeNav], AccountController.u
router.post('/account/checkverifycode', [getCommonHeader, getHomeNav], AccountController.checkVerifyCode);
router.post('/account/checkpassword', [getCommonHeader, getHomeNav], AccountController.checkPassword);
router.post('/account/verifypassword', [getCommonHeader, getHomeNav], AccountController.verifyPassword);
router.post('/account/modifypwd', [getCommonHeader, getHomeNav], AccountController.modifyPwd);
router.post('/account/checkemail', [getCommonHeader, getHomeNav], AccountController.checkEmail);
router.post('/account/modifyemail', [getCommonHeader, getHomeNav], AccountController.modifyEmail);
router.get('/account/sendemailsuccess', [getCommonHeader, getHomeNav], AccountController.sendEmailSuccess);
router.get('/favorite', FavoriteController.index);
router.get('/coupons', CouponsController.index);
... ...
... ... @@ -8,7 +8,7 @@
{{/each}}
</ul>
<div class="form-nav">
<input type="hidden" value="{{# verifyType}}{{verifyType}}{{/ verifyType}}" id="verifyType"/>
<input type="hidden" value="{{verifyType}}" id="verifyType"/>
{{#if returnInfo}}
{{# complete}}
<div class="result-info">
... ...
... ... @@ -105,14 +105,18 @@ function checkForm(dom) {
return checkFormAjax(ajaxData);
}
} else if (inputName === 'verifyCode') {
$.extend(ajaxData, {
url: '/home/account/checkverifycode',
data: {
verifyCode: val
},
txt: '验证码错误!'
});
return checkFormAjax(ajaxData);
if (len === 0) {
return errorInfoAction(opt, '验证码不能为空!');
} else {
$.extend(ajaxData, {
url: '/home/account/checkverifycode',
data: {
verifyCode: val
},
txt: '验证码错误!'
});
return checkFormAjax(ajaxData);
}
} else if (inputName === 'email') {
regular = phoneRegx.emailRegx;
... ... @@ -211,7 +215,7 @@ function checkAllForm() {
function changeCode() {
var timestamp = (new Date()).getTime();
$('#the-code-img').attr('src', '/passport/images?len=6&time=' + timestamp);
$('#the-code-img').attr('src', '/passport/imagesNode?len=6&time=' + timestamp);
}
// 重新发送倒计时
... ... @@ -301,6 +305,7 @@ function toHome() {
// ajax公共处理模块
function ajaxAction(opt, flag) {
$.post(opt.url, opt.data, function(data) {
console.info(data);
if (data.code === 200) {
if (flag) {
opt.hrefUrl += '&checkCode=' + data.data;
... ...