...
|
...
|
@@ -9,6 +9,7 @@ const library = '../../../library'; |
|
|
const helpers = require(`${library}/helpers`);
|
|
|
|
|
|
const service = require('../models/back-service');
|
|
|
const sessionService = require('../models/session-service');
|
|
|
|
|
|
// 本地地址 localhost
|
|
|
helpers.urlFormat = helpers.fakeUrlFormat;
|
...
|
...
|
@@ -32,17 +33,33 @@ module.exports.indexPage = (req, res) => { |
|
|
/**
|
|
|
* 校验用户输入信息,是否是已经注册的用户
|
|
|
*/
|
|
|
module.exports.identifyUserByInputAPI = (req, res) => {
|
|
|
module.exports.validateUserInputAPI = (req, res, next) => {
|
|
|
let userInput = req.body.phoneNum || '';
|
|
|
|
|
|
let areaCode = req.body.area || '86';
|
|
|
|
|
|
service.identifyUserByEmailOrMobileAsync(userInput, areaCode)
|
|
|
service.validateEmailOrMobileAsync(userInput, areaCode)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
req.inputInfo = result;
|
|
|
next();
|
|
|
})
|
|
|
.catch(err => {
|
|
|
res.json({
|
|
|
code: 400,
|
|
|
message: err
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports.getUserInfoAPI = (req, res, next) => {
|
|
|
let inputInfo = req.inputInfo;
|
|
|
|
|
|
service.findUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports.sendCodeAPI = (req, res, next) => {
|
|
|
let userInput = req.body.phoneNum || '';
|
|
|
|
...
|
...
|
@@ -68,6 +85,60 @@ module.exports.sendCodeAPI = (req, res, next) => { |
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports.sendBackMobileAPI = (req, res, next) => {
|
|
|
let mobile = req.param('mobile', '');
|
|
|
|
|
|
let area = req.param('area', '86');
|
|
|
|
|
|
service.sendCodeToMobileAsync(area, mobile)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports.sendEmailPage = (req, res, next) => {
|
|
|
service.getSendEmailPageDataAsync()
|
|
|
.then(result => {
|
|
|
res.render('back/send-email', Object.assign({
|
|
|
module: 'back',
|
|
|
page: 'send-email',
|
|
|
title: "邮件发送成功"
|
|
|
}, result
|
|
|
));
|
|
|
}).catch(next);
|
|
|
|
|
|
};
|
|
|
|
|
|
module.exports.checkEmailCodePage = (req, res, next) => {
|
|
|
let code = req.param('code', '');
|
|
|
|
|
|
service.checkEmailCodeAsync(code)
|
|
|
.then(result => {
|
|
|
if (result) {
|
|
|
next();
|
|
|
} else {
|
|
|
res.redirect('/passport/back/index.html');
|
|
|
}
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports.resetPasswordByEmailPage = (req, res, next) => {
|
|
|
let code = res.param('code', '');
|
|
|
|
|
|
service.getLeftBannerAsync()
|
|
|
.then(result => {
|
|
|
res.render('back/email-reset-pwd', Object.assign({
|
|
|
module: 'back',
|
|
|
page: 'email-reset-pwd'
|
|
|
}, {
|
|
|
code: code
|
|
|
}, result))
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 手机验证页面
|
|
|
*/
|
|
|
module.exports.verifyCodeByMobilePage = (req, res, next) => {
|
|
|
|
|
|
service.getVerifyCodeByMobilePageDataAsync()
|
...
|
...
|
@@ -87,3 +158,74 @@ module.exports.verifyCodeByMobilePage = (req, res, next) => { |
|
|
}));
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports.verifyCodeByMobileAPI = (req, res, next) => {
|
|
|
|
|
|
};
|
|
|
|
|
|
module.exports.checkSuccessStatusPage = (req, res, next) => {
|
|
|
let successType = sessionService.get('successType', '');
|
|
|
|
|
|
if (successType) {
|
|
|
sessionService.set('successType', '');
|
|
|
next();
|
|
|
} else {
|
|
|
res.redirect('/passport/back/index.html');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports.resetPwdSuccessPage = (req, res, next) => {
|
|
|
service.getLeftBannerAsync()
|
|
|
.then(result => {
|
|
|
res.render('back/email-reset-success', Object.assign({
|
|
|
module: 'back',
|
|
|
page: 'email-reset-success',
|
|
|
title: '重置密码成功'
|
|
|
}, result))
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
|
|
module.exports.verifyCodyByMobileAPI = (req, res, next) => {
|
|
|
|
|
|
let mobile = req.param('mobile', '');
|
|
|
|
|
|
let area = req.param('aera', '86');
|
|
|
|
|
|
let mobileCode = req.param('code', '');
|
|
|
|
|
|
service.verifyCodyByMobileAsync(area, mobile, mobileCode)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
}).catch(next);
|
|
|
|
|
|
};
|
|
|
|
|
|
module.exports.tokenCheckPage = (req, res, next) => {
|
|
|
let token = req.param('code', '');
|
|
|
|
|
|
service.authRequest(token).then(result => {
|
|
|
if (result) {
|
|
|
req.authInfo = result;
|
|
|
next();
|
|
|
} else {
|
|
|
res.redirect('/passport/back/index');
|
|
|
}
|
|
|
})
|
|
|
};
|
|
|
|
|
|
module.exports.validationPwdPage = (req, res, next) => {
|
|
|
let pwd = req.param('pwd', '');
|
|
|
|
|
|
if (helpers.verifyPassword(pwd)) {
|
|
|
res.redirect('/passport/back/index.html');
|
|
|
} else {
|
|
|
next();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
module.exports.updatePwdPage = (req, res, next) => {
|
|
|
|
|
|
let code = req.param('code', '');
|
|
|
|
|
|
let auth = req.authInfo;
|
|
|
}; |
...
|
...
|
|