router.js
6.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/**
* 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 bind = require(cRoot + '/bind');
const cert = require(cRoot + '/cert');
const auth = require(`${global.middleware}/auth`);
const router = express.Router(); // eslint-disable-line
// 兼容老的路由
router.get('/signin.html', login.common.beforeLogin, captcha.tryGeetest, login.local.loginPage);
router.get('/reg.html', reg.index);
router.get('/logout.html', login.local.logout);
// 本地登录
// 短信验证码
router.post('/passport/login/sms/send', captcha.requiredAPI, login.local.sms.send); // 发短信验证码
router.post('/passport/login/sms/auth', login.local.sms.auth); // 验证短信验证码
router.post('/passport/login/sms/checkuser', login.local.sms.checkUser); // 短信检查用户是否注册
// 二维码登录
router.post('/passport/login/qrcode/refresh', login.local.qrcode.refresh); // 刷新二维码
router.post('/passport/login/qrcode/check', login.local.qrcode.check); // 验证二维码的状态
router.get('/passport/login', login.common.beforeLogin, captcha.tryGeetest, login.local.loginPage);
router.post('/passport/login/auth', captcha.passwordRequired, login.local.login);
router.get('/passport/logout', login.local.logout);
// 微信登录
router.get('/passport/autosign/wechat', login.common.beforeLogin, login.wechat.login); // 微信登录, 兼容 PHP 的路径
router.get('/passport/login/wechat/callback', login.wechat.callback);
// sina登录
router.get('/passport/autosign/sina', login.common.beforeLogin, login.sina.login);
router.get('/passport/login/sina/callback', login.sina.callback);
// qq登录
router.get('/passport/autosign/qq', login.common.beforeLogin, login.qq.login);
router.get('/passport/login/qq/callback', login.qq.callback);
// alipay登录
router.get('/passport/autosign/alipay', login.common.beforeLogin, login.alipay.login);
router.get('/passport/login/alipay/callback', login.alipay.callback);
// douban登录
router.get('/passport/autosign/douban', login.common.beforeLogin, login.douban.login);
router.get('/passport/autosign/doubanback', login.douban.callback);
// renren登录
router.get('/passport/autosign/renren', login.common.beforeLogin, login.renren.login);
router.get('/passport/login/renren/callback', login.renren.callback);
router.get('/passport/login/account', login.common.needCaptcha);
// 第三方登录后绑定
router.get('/passport/thirdlogin/index', captcha.tryGeetest, bind.indexPage);
router.get('/passport/thirdlogin/bindsuccess', bind.bindSuccess);
router.post('/passport/thirdlogin/noregist', bind.noregist);
router.post('/passport/thirdlogin/checkCaptcha', captcha.requiredAPI, bind.captchaSuccess); // 图形验证码成功
router.post('/passport/thirdlogin/relate', bind.relate);
router.post('/passport/autouserinfo/bindCheck', bind.bindCheck);
router.post('/passport/autouserinfo/sendBindMsg', bind.sendBindMsg);
router.post('/passport/autouserinfo/checkBindMsg', bind.checkBindMsg);
router.post('/passport/autouserinfo/bindMobile', bind.bindMobile);
router.post('/passport/autouserinfo/relateMobile', bind.relateMobile);
// 未实名认证的老邮箱用户登录
router.get('/passport/cert/headerTip', cert.headerTip); /** 邮箱老用户头部提示 **/
router.get('/passport/cert/tip', auth, cert.tip); /** 提示是否完善资料页面 **/
router.get('/passport/cert/index', auth, cert.index); /** 输入手机号码页面 **/
router.post('/passport/cert/cert', auth, cert.cert); /** 认证页面 **/
router.post('/passport/cert/relate', auth, cert.relate); /** 关联页面 **/
router.get('/passport/cert/success', auth, cert.success); /** 成功提示页面 **/
router.post('/passport/cert/check', auth, cert.check);
router.post('/passport/cert/sendCertMsg', auth, cert.sendCertMsg);
/* router.post('/passport/cert/checkBindMsg', cert.checkBindMsg);*/
router.post('/passport/cert/certMobile', auth, cert.certMobile);
router.post('/passport/cert/relateMobile', auth, cert.relateMobile);
/**
* 注册页面路由
*/
router.get('/passport/reg/index', captcha.tryGeetest, reg.index);
// NOTE: 该接口的存在只是为了兼容前端 ajax 请求
router.post('/passport/reg/checkmobile', reg.fakeCheckMobile);
router.post('/passport/reg/msgcaptcha', reg.checkMobileMiddleware, reg.msgCaptcha);
router.post('/passport/reg/sendBindMsg',
captcha.requiredAPI,
reg.checkMobileMiddleware,
reg.sendBindMsg);
router.post('/passport/reg/mobileregister',
reg.checkMobileMiddleware,
reg.checkPassword,
reg.mobileRegister);
router.get('/passport/reg/success', reg.success);
/**
* 找回密码首页信息
*/
// 找回密码首页
router.get('/passport/back/index', captcha.tryGeetest, back.index);
// 验证输入是否正确
router.post('/passport/back/authcode',
captcha.requiredAPI,
back.validateInputAPI,
back.getUserInfoAPI);
// 提交按钮邮件API
router.post('/passport/back/email',
back.validateInputPage,
back.sendCodePage,
back.saveInSession);
// 提交按钮手机AP
router.post('/passport/back/mobile',
back.validateInputPage,
back.sendCodePage,
back.saveInSession);
/**
* 邮件找回密码
*/
// 发送邮件成功页面
router.get('/passport/back/sendEmail',
back.validateEmailInSession,
back.sendEmailPage);
/**
* 短信找回密码
*/
// 验证手机短信页面
router.get('/passport/back/verification',
back.validateMobileInSession,
back.verifyCodeByMobilePage);
// 重新发送短信接口
router.post('/passport/back/sendBackMobile', back.validateMobileAPI, back.sendBackMobileAPI);
// 验证手机验证码接口
router.post('/passport/back/backMobile', back.verifyCodeByMobileAPI);
/**
* 重置密码
*/
// 重置密码页面
router.get('/passport/back/backcode',
back.validateExistCodePage,
back.validateCodeByMobilePage,
back.validateCodeByEmailPage,
back.resetPasswordPage);
// 重置密码接口
router.post('/passport/back/update',
back.validateExistCodePage,
back.validateCodeByMobilePage,
back.validatePwdPage,
back.updatePwdAPI);
// 重置密码成功页面
router.get('/passport/back/resetSuccess',
back.validateSuccessStatusPage,
back.resetPwdSuccessPage);
router.get('/passport/images.png', captcha.generate);
router.post('/passport/captcha/img', captcha.checkAPI);
module.exports = router;