...
|
...
|
@@ -237,6 +237,8 @@ const sendCodeToMobileAPI = (req, res, next) => { |
|
|
_.set(req.session, 'backupCaptch.timeout', Date.now() + 5 * 60 * 1000);
|
|
|
}
|
|
|
|
|
|
req.session.backupCaptchStep2 = true; // 允许跳到第二步
|
|
|
|
|
|
return res.json({
|
|
|
code: 200,
|
|
|
data: helpers.urlFormat('/passport/back/mobilecode', {
|
...
|
...
|
@@ -286,14 +288,17 @@ const verifyCodeByMobileAPI = (req, res, next) => { |
|
|
|
|
|
service.validateMobileCodeAsync(phoneNum, code, areaCode)
|
|
|
.then(result => {
|
|
|
if (result.code === 200) {
|
|
|
if (result.code === 200 && result.data) {
|
|
|
req.session.backcode = {
|
|
|
phoneNum: phoneNum,
|
|
|
token: result.data.token,
|
|
|
areaCode: areaCode,
|
|
|
code: code
|
|
|
};
|
|
|
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: helpers.urlFormat('/passport/back/backcode', {
|
|
|
phoneNum: phoneNum,
|
|
|
token: result.data.token,
|
|
|
areaCode: areaCode
|
|
|
})
|
|
|
data: helpers.urlFormat('/passport/back/backcode')
|
|
|
});
|
|
|
} else {
|
|
|
res.json({
|
...
|
...
|
@@ -309,16 +314,15 @@ const verifyCodeByMobileAPI = (req, res, next) => { |
|
|
* 找回密码页面,设置新密码页面-手机
|
|
|
*/
|
|
|
const setNewPasswordByMobilePage = (req, res) => {
|
|
|
let phoneNum = req.query.phoneNum || '';
|
|
|
let token = req.query.token || '';
|
|
|
let areaCode = req.query.areaCode || '86';
|
|
|
let code = req.query.code || '';
|
|
|
let backcode = req.session.backcode;
|
|
|
|
|
|
if (!(code || (token && helpers.verifyMobile(phoneNum)))) {
|
|
|
if (!backcode || !(backcode.code || (backcode.token && helpers.verifyMobile(backcode.phoneNum)))) {
|
|
|
res.redirect(400);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
req.session.backcode = null;
|
|
|
|
|
|
res.render('back/new-password', Object.assign({
|
|
|
module: 'passport',
|
|
|
page: 'back-new-password',
|
...
|
...
|
@@ -328,10 +332,10 @@ const setNewPasswordByMobilePage = (req, res) => { |
|
|
headerText: '找回密码',
|
|
|
isPassportPage: true,
|
|
|
backNewPwd: true,
|
|
|
phoneNum: phoneNum,
|
|
|
token: token,
|
|
|
areaCode: areaCode,
|
|
|
code: code
|
|
|
phoneNum: backcode.phoneNum,
|
|
|
token: backcode.token,
|
|
|
areaCode: backcode.areaCode,
|
|
|
code: backcode.code
|
|
|
}));
|
|
|
};
|
|
|
|
...
|
...
|
@@ -361,6 +365,20 @@ const setNewPasswordByMobileAPI = (req, res, next) => { |
|
|
.catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 直接调用发短信接口的情况
|
|
|
*/
|
|
|
const verifySmsAllow = (req, res, next) => {
|
|
|
if (_.get(req, 'session.backupCaptch.verifyResult')) {
|
|
|
return next();
|
|
|
} else {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: '非法请求'
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
indexEmailPage,
|
|
|
sendCodeToEmailAPI,
|
...
|
...
|
@@ -373,5 +391,6 @@ module.exports = { |
|
|
verifyCodeByMobileAPI,
|
|
|
setNewPasswordByMobilePage,
|
|
|
setNewPasswordByMobileAPI,
|
|
|
generateCodeImg
|
|
|
generateCodeImg,
|
|
|
verifySmsAllow
|
|
|
}; |
...
|
...
|
|