router.js 1.69 KB
/**
 * router of sub app channel
 * @author: Bi Kai<kai.bi@yoho.cn>
 * @date: 2016/05/09
 */

'use strict';

const express = require('express');
const cRoot = './controllers';
const login = require(cRoot + '/login');

const Captcha = require(cRoot + '/captcha');
const Back = require(cRoot + '/back');

const router = express.Router(); // eslint-disable-line

router.get('/login/wechat', login.wechat.beforeLogin, login.wechat.login); // 登录
router.get('/login/wechat/callback', login.wechat.callback);

/**
 * 找回密码首页信息
 */
// 找回密码首页
router.get('/back/index.html', Back.indexPage);

// 实时验证输入是否正确
router.post('/back/authcode', Captcha.checkAPI, Back.validateUserInputAPI, Back.getUserInfoAPI);

// 提交按钮确定
router.post('/back/mobile', Captcha.checkPage, Back.validateUserInputAPI, Back.sendCodeAPI);

/**
 * 邮件找回密码
 */
// 发送邮件成功页面
router.get('/back/sendEmail.html', Back.sendEmailPage);

/**
 * 短信找回密码
 */
// 验证手机短信页面
router.get('/back/verification.html', Back.verifyCodeByMobilePage);

// 重新发送短信接口
router.post('/back/sendBackMobile', Captcha.checkAPI, Back.sendBackMobileAPI);

// 验证手机验证码接口
router.post('/back/backMobile', Captcha.checkAPI, Back.verifyCodyByMobileAPI);

/**
 * 重置密码
 */
// 重置密码页面
router.get('/back/backcode', Back.tokenCheckPage, Back.checkCodePage, Back.resetPasswordPage);

// 重置密码接口
router.post('/back/update', Back.tokenCheckPage, Back.validationPwdPage, Back.updatePwdPage);

// 重置密码成功页面
router.get('/back/resetSuccess.html', Back.checkSuccessStatusPage, Back.resetPwdSuccessPage);

module.exports = router;