router.js
8.6 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/**
* router of sub app channel
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
const express = require('express');
const login = require('./controllers/login');
const back = require('./controllers/back');
const bind = require('./controllers/bind');
const reg = require('./controllers/reg');
const reset = require('./controllers/reset');
const disableBFCahce = require('../../doraemon/middleware/disable-BFCache');
const smsLogin = require('./controllers/sms');
const update = require('./controllers/update');
const agreement = require('./controllers/app-agreement');
const geetest = require('./controllers/geetest');
const validateCode = require('./controllers/validateCode');
const router = express.Router(); // eslint-disable-line
// geetest
router.get('/passport/geetest/register', geetest.register);
// 兼容老的路由
// router.get('/signin.html', login.common.weixinCheck, validateCode.load,
// login.common.beforeLogin, login.common.clearCookie, smsLogin.loginPage);
// router.get('/reg.html', validateCode.load, disableBFCahce, reg.index);
// router.get('/login.html', validateCode.load,
// login.common.beforeLogin, login.common.clearCookie, login.local.international);
router.get('/phoneback.html', back.indexMobilePage);
router.get('/emailback.html', back.indexEmailPage);
// 登出
router.get('/passport/signout/index', login.common.clearCookie, login.local.logout);
// 登录页面
// router.get('/passport/login',
// validateCode.load,
// login.common.beforeLogin,
// login.common.clearCookie,
// login.loginShowCaptchaByIp,
// login.local.loginPage
// );
// router.get('/passport/international',
// validateCode.load,
// login.common.beforeLogin,
// login.common.clearCookie,
// login.loginShowCaptchaByIp,
// login.local.international
// );
// 本地登录
router.post('/passport/login/auth', validateCode.check, login.local.login);
// 检查登录状态
router.get('/passport/login/check', login.common.check);
// SMS 短信
// router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
// router.get('/passport/sms_login', validateCode.load, smsLogin.loginPage);
router.post('/passport/sms_login/step1_check', validateCode.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.common.isLoginUser, 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);
// 登录绑定
router.get('/passport/bind/index', validateCode.load, bind.indexPage);
router.post('/passport/bind/bindCheck', validateCode.check, 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', validateCode.load, reg.index);
router.post('/passport/reg/verifymobile', validateCode.check, 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/sendcodeagain', 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/password/resetpage', reset.passwordResetPage); // 重置密码页面
router.post('/passport/password/reset', reset.passwordReset); // 重置密码
router.get('/passport/password/resetsuccess', reset.passwordResetOkPage); // 重置成功
/**
* 密码找回
*/
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', validateCode.load, back.indexMobilePage);// 输入手机号找回密码页面
router.get('/passport/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面
router.get('/passport/back/generatecodeimg.png', back.generateCodeImg);// 生成图片验证码
router.post('/passport/back/sendcode', validateCode.check, back.sendCodeToMobileAPI);// 发送手机验证码
router.post('/passport/back/sendcodeagain', back.verifySmsAllow, 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);// 服务条款
router.get('/passport/about', agreement.about);// 关注有货
// 验证码
let captcha = require('./controllers/captcha');
router.get('/passport/captcha/get', captcha.get);
router.get('/passport/img-check.jpg', captcha.imgCheck);
// 新的登录注册
const LoginNew = require('./controllers/login-new');
const loginNew = new LoginNew();
const RegNew = require('./controllers/reg-new');
const regNew = new RegNew();
const SmsNew = require('./controllers/sms-new');
const smsNew = new SmsNew();
const BackNew = require('./controllers/back-new');
const backNew = new BackNew();
router.get('/passport/login',
validateCode.load,
login.common.beforeLogin,
login.common.clearCookie,
login.loginShowCaptchaByIp,
loginNew.loginPage); // 普通登录
router.get('/passport/international',
validateCode.load,
login.common.beforeLogin,
login.common.clearCookie,
login.loginShowCaptchaByIp,
loginNew.international); // 国际账号登录
router.get('/passport/reg/index',
validateCode.load,
regNew.regPage); // 注册页面
router.post('/passport/register-new',
reg.sendCodeBusyBoy,
regNew.register); // 注册请求
router.get('/passport/sms_login',
validateCode.load,
smsNew.smsLoginPage); // 短信验证码登录
// 兼容老的路由
router.get('/signin.html',
login.common.weixinCheck,
validateCode.load,
login.common.beforeLogin,
login.common.clearCookie,
login.common.thirdLogin,
smsNew.smsLoginPage); // 短信验证码登录
router.get('/reg.html',
validateCode.load,
regNew.regPage); // 注册页面
router.get('/login.html',
validateCode.load,
login.common.beforeLogin,
login.common.clearCookie,
login.loginShowCaptchaByIp,
loginNew.international); // 国际账号登录
router.get('/passport/back/mobile-new', backNew.backByMobile); // 通过手机找回密码
router.get('/passport/back/email-new', backNew.backByEmail); // 通过邮箱找回密码
router.get('/passport/back/email-success-new', backNew.backByEmailSuccess); // 通过邮箱找回密码成功页
module.exports = router;