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

const disableBFCahce = require('../../doraemon/middleware/disable-BFCache');

const smsLogin = require(cRoot + '/sms');
const update = require(cRoot + '/update');
const agreement = require(cRoot + '/app-agreement');

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

// 兼容老的路由
// router.get('/signin.html', login.common.beforeLogin, login.local.loginPage);
router.get('/signin.html', smsLogin.loginPage);
router.get('/reg.html', disableBFCahce, reg.index);
router.get('/login.html', login.common.beforeLogin, login.local.international);
router.get('/phoneback.html', back.indexMobilePage);
router.get('/emailback.html', back.indexEmailPage);

// 登出
router.get('/passport/signout/index', login.local.logout);

// 登录页面
// router.get('/passport/login', login.common.beforeLogin, login.local.loginPage);
router.get('/passport/login', smsLogin.loginPage);
router.get('/passport/international', login.common.beforeLogin, login.local.international);

// 本地登录
router.post('/passport/login/auth', login.local.login);

// SMS 短信
router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
router.get('/passport/sms_login', smsLogin.loginPage);
router.post('/passport/sms_login/step1_check', smsLogin.indexCheck);
router.get('/passport/sms_login/token.json',
    smsLogin.tokenBefore,
    smsLogin.token); // only ajax;
router.get('/passport/sms_login/check.json',
    smsLogin.checkBefore,
    smsLogin.check); // only ajax
router.post('/passport/sms_login/password.json', smsLogin.password);

// jsonp获取用户uid
router.get('/passport/login/user', login.user);

// 微信登录
router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login);
router.get('/passport/login/wechat/callback', login.wechat.callback);

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

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

// 支付宝登录
router.get('/passport/login/alipay', login.common.beforeLogin, login.alipay.login);
router.get('/passport/login/alipay/callback', login.alipay.callback);

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

// 登录绑定
router.get('/passport/bind/index', bind.indexPage);
router.post('/passport/bind/bindCheck', bind.bindCheck);
router.get('/passport/bind/code', bind.codePage);
router.post('/passport/bind/sendBindMsg',
    bind.sendBefore,
    bind.sendBindMsg);
router.post('/passport/bind/bindMobile', bind.bindMobile);

router.post('/passport/bind/relateMobile', bind.relateMobile);
router.get('/passport/bind/password', bind.passwordPage);
router.get('/passport/bind/success', bind.successPage);

router.post('/passport/bind/changeCheck', bind.changeCheck);
router.post('/passport/bind/changeMobile', bind.changeMobile);

/**
 * 注册
 */
router.use('/passport/reg/*', disableBFCahce);
router.get('/passport/reg/index', reg.index);
router.get('/passport/reg/captcha.png', reg.genCaptcha);
router.post('/passport/reg/verifymobile', reg.sendCodeBusyBoy, reg.verifyMobile);
router.get('/passport/reg/code', reg.guardStep(2), reg.code);
router.post('/passport/reg/sendcode', reg.guardStep(2), reg.sendCodeBusyBoy, reg.sendCode);
router.post('/passport/reg/verifycode', reg.guardStep(2), reg.verifyCode);
router.get('/passport/reg/password', reg.guardStep(3), reg.password);
router.post('/passport/reg/setpassword', reg.guardStep(3), reg.setPassword);

/**
 * 密码找回
 */
router.get('/passport/back/email', back.indexEmailPage);// 通过邮箱找回密码页面
router.post('/passport/back/sendemail', back.sendCodeToEmailAPI);// 发送邮箱验证码
router.get('/passport/back/resendemail', back.resendCodeToEmailAPI);// 重新发送邮箱验证码
router.get('/passport/back/success', back.backSuccessByEmailPage);// 邮箱找回密码-发送成功页面

router.get('/passport/back/mobile', back.indexMobilePage);// 输入手机号找回密码页面
router.get('/passport/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面
router.get('/passport/back/generatecodeimg.png', back.generateCodeImg);// 生成图片验证码
router.post('/passport/back/sendcode', back.sendCodeToMobileAPI);// 发送手机验证码
router.post('/passport/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码

router.get('/passport/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面
router.post('/passport/back/passwordbyemail', back.setNewPasswordByEmailAPI);// 依据邮箱验证码修改密码
router.post('/passport/back/passwordbymobile', back.setNewPasswordByMobileAPI);// 依据手机验证码修改密码

/**
 * 提示升级app
 */
router.get('/passport/update', update.index);

// 服务条款
router.get('/passport/privacy', agreement.privacy);// 隐私条款
router.get('/passport/newpower', agreement.newpower);// 新力传媒
router.get('/passport/yohobuy', agreement.aboutYoho);// 关于有货
router.get('/passport/agreement', agreement.agreement);// 服务条款

// 验证码
let captcha = require(`${cRoot}/captcha`);

router.get('/passport/captcha/get', captcha.get);

module.exports = router;