router.js 3.21 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 reg = require(cRoot + '/reg');

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

// 本地登录
router.get('/login', login.common.beforeLogin, login.local.loginPage);
router.post('/login/auth', login.local.login);
router.get('/logout', login.local.logout);

// 微信登录
router.get('/autosign/wechat', login.common.beforeLogin, login.wechat.login); // 微信登录, 兼容 PHP 的路径
router.get('/login/wechat/callback', login.wechat.callback);

// sina登录
router.get('/autosign/sina', login.common.beforeLogin, login.sina.login);
router.get('/login/sina/callback', login.sina.callback);

// qq登录
router.get('/autosign/qq', login.common.beforeLogin, login.qq.login);
router.get('/login/qq/callback', login.qq.callback);

// alipay登录
router.get('/autosign/alipay', login.common.beforeLogin, login.alipay.login);
router.get('/login/alipay/callback', login.alipay.callback);

/**
 * 注册页面路由
 */
router.get('/reg/index', reg.index);
router.post('/reg/checkmobile', reg.checkMobile);
router.post('/reg/piccaptcha', reg.picCaptcha);
router.post('/reg/msgcaptcha', reg.msgCaptcha);
router.post('/reg/sendBindMsg', reg.sendBindMsg);
router.post('/reg/mobileregister', reg.mobileRegister);
router.get('/reg/success', reg.success);

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

// 实时验证输入是否正确
router.post('/back/authcode',

    // captcha.requiredAPI,
    back.validateInputAPI,
    back.getUserInfoAPI);

// 提交按钮邮件API
router.post('/back/email',

    // captcha.requiredPage,
    back.validateUserPage,
    back.sendCodePage,
    back.saveInSession);

// 提交按钮手机API
router.post('/back/mobile',

    // captcha.requiredPage,
    back.validateUserPage,
    back.sendCodePage,
    back.saveInSession);

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

/**
 * 短信找回密码
 */
    // 验证手机短信页面
router.get('/back/verification',
    back.validateMobileInSession,

    // captcha.requiredPage,
    back.verifyCodeByMobilePage);

// 重新发送短信接口
router.post('/back/sendBackMobile',

    // captcha.requiredAPI,
    back.validateMobileAPI,
    back.sendBackMobileAPI);

// 验证手机验证码接口
router.post('/back/backMobile',

    // captcha.requiredAPI,
    back.verifyCodeByMobileAPI);

/**
 * 重置密码
 */

// 重置密码页面
router.get('/back/backcode',
    back.validateExistCodePage,
    back.validateCodeByMobilePage,
    back.validateCodeByEmailPage,
    back.resetPasswordPage);

// 重置密码接口
router.post('/back/update',
    back.validateExistCodePage,
    back.validateCodeByMobilePage,
    back.validatePwdPage,
    back.updatePwdAPI);

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

module.exports = router;