...
|
...
|
@@ -6,12 +6,12 @@ |
|
|
'use strict';
|
|
|
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const service = require('../models/back-service');
|
|
|
const passportHelper = require('../models/passport-helper');
|
|
|
const BackService = require('../models/back-service');
|
|
|
const PassportHelper = require('../models/passport-helper');
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
const index = (req, res, next) => {
|
|
|
service.indexPageDataAsync()
|
|
|
BackService.indexPageDataAsync()
|
|
|
.then(result => {
|
|
|
res.display('back/index', Object.assign({
|
|
|
module: 'passport',
|
...
|
...
|
@@ -27,7 +27,7 @@ const validateInputAPI = (req, res, next) => { |
|
|
let userInput = req.body.phoneNum || '';
|
|
|
let areaCode = (req.body.area || '86').replace('+', '');
|
|
|
|
|
|
service.validateEmailOrMobileAsync(userInput, areaCode)
|
|
|
BackService.validateEmailOrMobileAsync(userInput, areaCode)
|
|
|
.then(result => {
|
|
|
req.inputInfo = result;
|
|
|
next();
|
...
|
...
|
@@ -44,7 +44,7 @@ const validateInputPage = (req, res, next) => { |
|
|
let userInput = req.body.phoneNum || '';
|
|
|
let areaCode = (req.body.area || '86').replace('+', '');
|
|
|
|
|
|
service.validateEmailOrMobileAsync(userInput, areaCode)
|
|
|
BackService.validateEmailOrMobileAsync(userInput, areaCode)
|
|
|
.then(result => {
|
|
|
req.inputInfo = result;
|
|
|
next();
|
...
|
...
|
@@ -57,7 +57,7 @@ const validateInputPage = (req, res, next) => { |
|
|
const getUserInfoAPI = (req, res, next) => {
|
|
|
let inputInfo = req.inputInfo;
|
|
|
|
|
|
service.findUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
|
|
BackService.findUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
})
|
...
|
...
|
@@ -67,7 +67,7 @@ const getUserInfoAPI = (req, res, next) => { |
|
|
const sendCodePage = (req, res, next) => {
|
|
|
let inputInfo = req.inputInfo;
|
|
|
|
|
|
service.sendCodeToUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
|
|
BackService.sendCodeToUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
|
|
|
.then(result => {
|
|
|
if (!(result.code && result.code === 200)) {
|
|
|
return res.redirect(helpers.urlFormat('/passport/back/index'));
|
...
|
...
|
@@ -100,7 +100,7 @@ const sendBackMobileAPI = (req, res, next) => { |
|
|
let mobile = req.body.mobile || '';
|
|
|
let area = req.body.area || '86';
|
|
|
|
|
|
service.sendCodeToMobileAsync(area, mobile)
|
|
|
BackService.sendCodeToMobileAsync(area, mobile)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
})
|
...
|
...
|
@@ -111,7 +111,7 @@ const validateMobileAPI = (req, res, next) => { |
|
|
let mobile = req.body.mobile || '';
|
|
|
const ERR = {code: 400, message: '验证失败'};
|
|
|
|
|
|
if (!passportHelper.validator.verifyMobile(mobile)) {
|
|
|
if (!PassportHelper.validator.verifyMobile(mobile)) {
|
|
|
return res.json(ERR);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -154,7 +154,7 @@ const validateCodeByEmailPage = (req, res, next) => { |
|
|
return next();
|
|
|
}
|
|
|
|
|
|
service.checkEmailCodeAsync(code)
|
|
|
BackService.checkEmailCodeAsync(code)
|
|
|
.then(result => {
|
|
|
if (!result) {
|
|
|
return res.redirect(helpers.urlFormat('/passport/back/index'));
|
...
|
...
|
@@ -232,7 +232,7 @@ const verifyCodeByMobileAPI = (req, res) => { |
|
|
return res.json(ERR);
|
|
|
}
|
|
|
|
|
|
service.verifyCodyByMobileAsync(area, mobile, mobileCode)
|
|
|
BackService.verifyCodyByMobileAsync(area, mobile, mobileCode)
|
|
|
.then(result => {
|
|
|
res.json(result);
|
|
|
})
|
...
|
...
|
@@ -271,7 +271,7 @@ const validateCodeByMobilePage = (req, res, next) => { |
|
|
};
|
|
|
|
|
|
code = new Buffer(code, 'base64').toString();
|
|
|
req.mobileAuth = service.authRequest(data, code);
|
|
|
req.mobileAuth = BackService.authRequest(data, code);
|
|
|
|
|
|
next();
|
|
|
};
|
...
|
...
|
@@ -279,7 +279,7 @@ const validateCodeByMobilePage = (req, res, next) => { |
|
|
const validatePwdPage = (req, res, next) => {
|
|
|
let pwd = req.body.pwd || '';
|
|
|
|
|
|
if (!passportHelper.validator.isPassword(pwd)) {
|
|
|
if (!PassportHelper.validator.verifyPassword(pwd)) {
|
|
|
return res.redirect(helpers.urlFormat('/passport/back/index'));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -291,7 +291,7 @@ const updatePwdAPI = (req, res, next) => { |
|
|
let mobileAuth = req.mobileAuth || {};
|
|
|
let newPassword = req.body.pwd || '';
|
|
|
|
|
|
service.updatePwdAsync(code, mobileAuth, newPassword)
|
|
|
BackService.updatePwdAsync(code, mobileAuth, newPassword)
|
|
|
.then(result => {
|
|
|
if (result.status) {
|
|
|
req.session.successType = result.type;
|
...
|
...
|
|