Showing
14 changed files
with
260 additions
and
272 deletions
@@ -6,76 +6,74 @@ | @@ -6,76 +6,74 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | - | ||
10 | const library = '../../../library'; | 9 | const library = '../../../library'; |
11 | const helpers = require(`${library}/helpers`); | 10 | const helpers = require(`${library}/helpers`); |
12 | - | ||
13 | const service = require('../models/back-service'); | 11 | const service = require('../models/back-service'); |
14 | 12 | ||
15 | -const SIGN_IN_URL = helpers.urlFormat('/signin.html'); | 13 | +const SIGN_IN = helpers.urlFormat('/passport/login'); |
16 | 14 | ||
17 | /** | 15 | /** |
18 | * 通过邮箱找回密码页面 | 16 | * 通过邮箱找回密码页面 |
19 | */ | 17 | */ |
20 | -module.exports.indexByEmailPage = (req, res) => { | ||
21 | - | ||
22 | - let data = { | ||
23 | - backUrl: SIGN_IN_URL, | ||
24 | - headerText: '找回密码', | ||
25 | - isPassportPage: true, | ||
26 | - backEmail: true | ||
27 | - }; | ||
28 | - | 18 | +const indexEmailPage = (req, res) => { |
29 | res.render('back/email', Object.assign({ | 19 | res.render('back/email', Object.assign({ |
30 | module: 'passport', | 20 | module: 'passport', |
31 | - page: 'back-email', | ||
32 | - title: '找回密码-通过邮箱' | ||
33 | - }, data)); | 21 | + page : 'back-email', |
22 | + title : '找回密码-通过邮箱' | ||
23 | + }, { | ||
24 | + backUrl : SIGN_IN, | ||
25 | + headerText : '找回密码', | ||
26 | + isPassportPage: true, | ||
27 | + backEmail : true | ||
28 | + })); | ||
34 | }; | 29 | }; |
35 | 30 | ||
36 | /** | 31 | /** |
37 | * 发送验证码到邮箱 | 32 | * 发送验证码到邮箱 |
38 | */ | 33 | */ |
39 | -module.exports.sendCodeToEmailAPI = (req, res) => { | 34 | +const sendCodeToEmailAPI = (req, res) => { |
40 | let email = req.body.email || ''; | 35 | let email = req.body.email || ''; |
41 | - | ||
42 | - let error = { | ||
43 | - code: 400, | 36 | + const ERR = { |
37 | + code : 400, | ||
44 | message: '邮箱格式不正确,请重新输入', | 38 | message: '邮箱格式不正确,请重新输入', |
45 | - data: '' | 39 | + data : '' |
46 | }; | 40 | }; |
47 | 41 | ||
48 | if (!helpers.verifyEmail(email)) { | 42 | if (!helpers.verifyEmail(email)) { |
49 | - res.json(error); | 43 | + res.json(ERR); |
50 | return; | 44 | return; |
51 | } | 45 | } |
52 | 46 | ||
53 | - service.sendCodeToEmailAsync(email).then(result => { | 47 | + service.sendCodeToEmailAsync(email) |
48 | + .then(result => { | ||
54 | if (result.code === 200) { | 49 | if (result.code === 200) { |
55 | - result.data = helpers.urlFormat('/passport/back/success.html', {email: email}); | 50 | + result.data = helpers.urlFormat('/passport/back/success', {email: email}); |
56 | } | 51 | } |
57 | 52 | ||
58 | res.json(result); | 53 | res.json(result); |
59 | - }).catch(() => { | ||
60 | - res.json(error); | 54 | + }) |
55 | + .catch(() => { | ||
56 | + res.json(ERR); | ||
61 | }); | 57 | }); |
62 | }; | 58 | }; |
63 | 59 | ||
64 | /** | 60 | /** |
65 | * 重新发送验证码到邮箱 | 61 | * 重新发送验证码到邮箱 |
66 | */ | 62 | */ |
67 | -module.exports.resendCodeToEmailAPI = (req, res) => { | 63 | +const resendCodeToEmailAPI = (req, res) => { |
68 | let email = req.query.email || ''; | 64 | let email = req.query.email || ''; |
69 | 65 | ||
70 | - service.sendCodeToEmailAsync(email).then(result => { | 66 | + service.sendCodeToEmailAsync(email) |
67 | + .then(result => { | ||
71 | if (_.isEmpty(result)) { | 68 | if (_.isEmpty(result)) { |
72 | return Promise.rejected('重新发邮件失败'); | 69 | return Promise.rejected('重新发邮件失败'); |
73 | } | 70 | } |
74 | 71 | ||
75 | res.json(result); | 72 | res.json(result); |
76 | - }).catch(err => { | 73 | + }) |
74 | + .catch(err => { | ||
77 | res.json({ | 75 | res.json({ |
78 | - code: 400, | 76 | + code : 400, |
79 | message: err | 77 | message: err |
80 | }); | 78 | }); |
81 | }); | 79 | }); |
@@ -84,7 +82,7 @@ module.exports.resendCodeToEmailAPI = (req, res) => { | @@ -84,7 +82,7 @@ module.exports.resendCodeToEmailAPI = (req, res) => { | ||
84 | /** | 82 | /** |
85 | * 邮箱找回密码-返回成功页面 | 83 | * 邮箱找回密码-返回成功页面 |
86 | */ | 84 | */ |
87 | -module.exports.backSuccessByEmailPage = (req, res) => { | 85 | +const backSuccessByEmailPage = (req, res) => { |
88 | let email = req.query.email || ''; | 86 | let email = req.query.email || ''; |
89 | 87 | ||
90 | if (!helpers.verifyEmail(email)) { | 88 | if (!helpers.verifyEmail(email)) { |
@@ -92,46 +90,43 @@ module.exports.backSuccessByEmailPage = (req, res) => { | @@ -92,46 +90,43 @@ module.exports.backSuccessByEmailPage = (req, res) => { | ||
92 | } | 90 | } |
93 | 91 | ||
94 | let domain = email.split('@')[1]; | 92 | let domain = email.split('@')[1]; |
95 | - | ||
96 | let emailUrl = `http://${domain === 'gmail.com' ? 'mail.google.com' : 'mail.'}${domain}`; | 93 | let emailUrl = `http://${domain === 'gmail.com' ? 'mail.google.com' : 'mail.'}${domain}`; |
97 | 94 | ||
98 | - | ||
99 | res.render('back/email-success', Object.assign({ | 95 | res.render('back/email-success', Object.assign({ |
100 | module: 'passport', | 96 | module: 'passport', |
101 | - page: 'back-email-success', | ||
102 | - title: '找回密码-通过邮箱' | 97 | + page : 'back-email-success', |
98 | + title : '找回密码-通过邮箱' | ||
103 | }, { | 99 | }, { |
104 | - backUrl: helpers.urlFormat('/passport/back/email.html'), | ||
105 | - headerText: '找回密码', | ||
106 | - isPassportPage: true, | 100 | + backUrl : helpers.urlFormat('/passport/back/email'), |
101 | + headerText : '找回密码', | ||
102 | + isPassportPage : true, | ||
107 | backEmailSuccess: true, | 103 | backEmailSuccess: true, |
108 | - goEmail: emailUrl, | ||
109 | - resendUrl: helpers.urlFormat('/passport/back/resendemail', {email: email}) | 104 | + goEmail : emailUrl, |
105 | + resendUrl : helpers.urlFormat('/passport/back/resendemail', {email: email}) | ||
110 | })); | 106 | })); |
111 | }; | 107 | }; |
112 | 108 | ||
113 | - | ||
114 | /** | 109 | /** |
115 | * 根据邮箱修改密码 | 110 | * 根据邮箱修改密码 |
116 | */ | 111 | */ |
117 | -module.exports.setNewPasswordByEmailAPI = (req, res) => { | 112 | +const setNewPasswordByEmailAPI = (req, res) => { |
118 | let pwd = req.body.password || ''; | 113 | let pwd = req.body.password || ''; |
119 | - | ||
120 | let code = req.body.code || ''; | 114 | let code = req.body.code || ''; |
121 | - | ||
122 | let data = { | 115 | let data = { |
123 | code: 200, | 116 | code: 200, |
124 | - data: SIGN_IN_URL | 117 | + data: SIGN_IN |
125 | }; | 118 | }; |
126 | 119 | ||
127 | - service.modifyPasswordByEmailAsync(pwd, code).then(result => { | 120 | + service.modifyPasswordByEmailAsync(pwd, code) |
121 | + .then(result => { | ||
128 | if (result.includes('history.back')) { | 122 | if (result.includes('history.back')) { |
129 | data.code = 400; | 123 | data.code = 400; |
130 | data.message = '修改失败'; | 124 | data.message = '修改失败'; |
131 | } | 125 | } |
132 | 126 | ||
133 | res.json(data); | 127 | res.json(data); |
134 | - }).catch(() => { | 128 | + }) |
129 | + .catch(() => { | ||
135 | res.json(data); | 130 | res.json(data); |
136 | }); | 131 | }); |
137 | }; | 132 | }; |
@@ -139,85 +134,78 @@ module.exports.setNewPasswordByEmailAPI = (req, res) => { | @@ -139,85 +134,78 @@ module.exports.setNewPasswordByEmailAPI = (req, res) => { | ||
139 | /** | 134 | /** |
140 | * 找回密码页面-通过手机号 | 135 | * 找回密码页面-通过手机号 |
141 | */ | 136 | */ |
142 | -module.exports.indexByMobilePage = (req, res, next) => { | ||
143 | - | 137 | +const indexMobilePage = (req, res, next) => { |
144 | service.getAreaDataAsync() | 138 | service.getAreaDataAsync() |
145 | .then(result => { | 139 | .then(result => { |
146 | res.render('back/mobile', Object.assign({ | 140 | res.render('back/mobile', Object.assign({ |
147 | module: 'passport', | 141 | module: 'passport', |
148 | - page: 'back-mobile', | ||
149 | - title: '找回密码-通过手机号' | 142 | + page : 'back-mobile', |
143 | + title : '找回密码-通过手机号' | ||
150 | }, { | 144 | }, { |
151 | - backUrl: SIGN_IN_URL, | ||
152 | - headerText: '找回密码', | 145 | + backUrl : SIGN_IN, |
146 | + headerText : '找回密码', | ||
153 | isPassportPage: true, | 147 | isPassportPage: true, |
154 | - backMobile: true, | ||
155 | - countrys: result.data, | ||
156 | - areaCode: '+86' | 148 | + backMobile : true, |
149 | + countrys : result.data, | ||
150 | + areaCode : '+86' | ||
157 | })); | 151 | })); |
158 | - }).catch(next); | 152 | + }) |
153 | + .catch(next); | ||
159 | }; | 154 | }; |
160 | 155 | ||
161 | /** | 156 | /** |
162 | * 发送手机验证码 | 157 | * 发送手机验证码 |
163 | */ | 158 | */ |
164 | -module.exports.sendCodeToMobileAPI = (req, res) => { | ||
165 | - let result = { | ||
166 | - code: 400, | ||
167 | - message: '密码只能使用数字、字母和半角标点符号,请重新输入', | ||
168 | - data: '' | ||
169 | - }; | ||
170 | - | 159 | +const sendCodeToMobileAPI = (req, res, next) => { |
171 | let phoneNum = req.body.phoneNum || ''; | 160 | let phoneNum = req.body.phoneNum || ''; |
172 | - | ||
173 | let areaCode = req.body.areaCode || '86'; | 161 | let areaCode = req.body.areaCode || '86'; |
162 | + let ERR = { | ||
163 | + code : 400, | ||
164 | + message: '输入手机号码出错' | ||
165 | + }; | ||
174 | 166 | ||
175 | if (!helpers.verifyMobile(phoneNum)) { | 167 | if (!helpers.verifyMobile(phoneNum)) { |
176 | - res.json(result); | ||
177 | - return; | 168 | + return res.json(ERR); |
178 | } | 169 | } |
179 | 170 | ||
180 | - service.sendCodeToMobileAsync(phoneNum, areaCode).then(data=> { | ||
181 | - if (_.isEmpty(data)) { | ||
182 | - return Promise.rejected('发送验证码出错'); | 171 | + service.sendCodeToMobileAsync(phoneNum, areaCode) |
172 | + .then(result => { | ||
173 | + if (_.isEmpty(result) || result.code !== 200) { | ||
174 | + ERR.message = "发送验证码出错"; | ||
175 | + res.json(ERR); | ||
183 | } | 176 | } |
184 | 177 | ||
185 | - if (data.code === 200) { | ||
186 | - result.data = helpers.urlFormat('/passport/back/verifycode', { | 178 | + if (result.code === 200) { |
179 | + return res.json({ | ||
180 | + code: 200, | ||
181 | + data: helpers.urlFormat('/passport/back/mobilecode', { | ||
187 | phoneNum: phoneNum, | 182 | phoneNum: phoneNum, |
188 | areaCode: areaCode | 183 | areaCode: areaCode |
184 | + }) | ||
189 | }); | 185 | }); |
190 | - | ||
191 | - res.json(result); | ||
192 | - } else { | ||
193 | - return Promise.rejected('发送验证码出错'); | ||
194 | } | 186 | } |
195 | - }).catch(err => { | ||
196 | - result.message = err; | ||
197 | - res.json(result); | ||
198 | - }); | ||
199 | - | 187 | + }) |
188 | + .catch(next); | ||
200 | }; | 189 | }; |
201 | 190 | ||
202 | /** | 191 | /** |
203 | * 校验验证码页面 | 192 | * 校验验证码页面 |
204 | */ | 193 | */ |
205 | -module.exports.verifyCodeByMobilePage = (req, res) => { | 194 | +const verifyCodeByMobilePage = (req, res) => { |
206 | let phoneNum = req.query.phoneNum || ''; | 195 | let phoneNum = req.query.phoneNum || ''; |
207 | - | ||
208 | let areaCode = req.query.areaCode || '86'; | 196 | let areaCode = req.query.areaCode || '86'; |
209 | 197 | ||
210 | res.render('back/mobile-code', Object.assign({ | 198 | res.render('back/mobile-code', Object.assign({ |
211 | module: 'passport', | 199 | module: 'passport', |
212 | - page: 'back-code', | ||
213 | - title: '找回密码-通过手机号' | 200 | + page : 'back-code', |
201 | + title : '找回密码-通过手机号' | ||
214 | }, { | 202 | }, { |
215 | - backUrl: helpers.urlFormat('/passport/back/mobile.html'), | ||
216 | - headerText: '找回密码', | 203 | + backUrl : helpers.urlFormat('/passport/back/mobile'), |
204 | + headerText : '找回密码', | ||
217 | isPassportPage: true, | 205 | isPassportPage: true, |
218 | - backCode: true, | ||
219 | - areaCode: areaCode, | ||
220 | - phoneNum: phoneNum | 206 | + backCode : true, |
207 | + areaCode : areaCode, | ||
208 | + phoneNum : phoneNum | ||
221 | 209 | ||
222 | })); | 210 | })); |
223 | }; | 211 | }; |
@@ -225,78 +213,99 @@ module.exports.verifyCodeByMobilePage = (req, res) => { | @@ -225,78 +213,99 @@ module.exports.verifyCodeByMobilePage = (req, res) => { | ||
225 | /** | 213 | /** |
226 | * 校验手机验证码 | 214 | * 校验手机验证码 |
227 | */ | 215 | */ |
228 | -module.exports.verifyCodeByMobileAPI = (req, res) => { | 216 | +const verifyCodeByMobileAPI = (req, res, next) => { |
229 | let phoneNum = req.body.phoneNum || ''; | 217 | let phoneNum = req.body.phoneNum || ''; |
230 | - | ||
231 | let code = req.body.code || ''; | 218 | let code = req.body.code || ''; |
232 | - | ||
233 | let areaCode = req.body.areaCode || '86'; | 219 | let areaCode = req.body.areaCode || '86'; |
234 | 220 | ||
235 | service.validateMobileCodeAsync(phoneNum, code, areaCode) | 221 | service.validateMobileCodeAsync(phoneNum, code, areaCode) |
236 | .then(result => { | 222 | .then(result => { |
237 | if (result.code === 200) { | 223 | if (result.code === 200) { |
238 | - result.data = helpers.urlFormat('/passport/back/backcode.html', { | 224 | + res.json({ |
225 | + code: 200, | ||
226 | + data: helpers.urlFormat('/passport/back/backcode', { | ||
239 | phoneNum: phoneNum, | 227 | phoneNum: phoneNum, |
240 | - token: result.data.token, | 228 | + token : result.data.token, |
241 | areaCode: areaCode | 229 | areaCode: areaCode |
242 | - }); | 230 | + }) |
231 | + }) | ||
232 | + } else { | ||
233 | + res.json({ | ||
234 | + code : 400, | ||
235 | + message: '验证码失败' | ||
236 | + }) | ||
243 | } | 237 | } |
244 | - | ||
245 | - res.json(result); | ||
246 | - }).catch(() => res.json({code: 400, message: '验证码失败'})); | 238 | + }) |
239 | + .catch(next); | ||
247 | }; | 240 | }; |
248 | 241 | ||
249 | /** | 242 | /** |
250 | * 找回密码页面,设置新密码页面-手机 | 243 | * 找回密码页面,设置新密码页面-手机 |
251 | */ | 244 | */ |
252 | -module.exports.setNewPasswordByMobilePage = (req, res) => { | 245 | +const setNewPasswordByMobilePage = (req, res) => { |
253 | let phoneNum = req.query.phoneNum || ''; | 246 | let phoneNum = req.query.phoneNum || ''; |
254 | - | ||
255 | let token = req.query.token || ''; | 247 | let token = req.query.token || ''; |
256 | - | ||
257 | let areaCode = req.query.areaCode || '86'; | 248 | let areaCode = req.query.areaCode || '86'; |
258 | - | ||
259 | let code = req.query.code || ''; | 249 | let code = req.query.code || ''; |
260 | 250 | ||
261 | - if (!token || (!helpers.verifyMobile(phoneNum) && !code)) { | 251 | + if (!(code || (token && helpers.verifyMobile(phoneNum)))) { |
262 | res.redirect(400); | 252 | res.redirect(400); |
263 | return; | 253 | return; |
264 | } | 254 | } |
265 | 255 | ||
266 | res.render('back/new-password', Object.assign({ | 256 | res.render('back/new-password', Object.assign({ |
267 | module: 'passport', | 257 | module: 'passport', |
268 | - page: 'back-new-password', | ||
269 | - title: '找回密码-输入新密码' | 258 | + page : 'back-new-password', |
259 | + title : '找回密码-输入新密码' | ||
270 | }, { | 260 | }, { |
271 | - backUrl: SIGN_IN_URL, | ||
272 | - headerText: '找回密码', | 261 | + backUrl : SIGN_IN, |
262 | + headerText : '找回密码', | ||
273 | isPassportPage: true, | 263 | isPassportPage: true, |
274 | - backNewPwd: true, | ||
275 | - phoneNum: phoneNum, | ||
276 | - token: token, | ||
277 | - areaCode: areaCode, | ||
278 | - code: code | 264 | + backNewPwd : true, |
265 | + phoneNum : phoneNum, | ||
266 | + token : token, | ||
267 | + areaCode : areaCode, | ||
268 | + code : code | ||
279 | })); | 269 | })); |
280 | }; | 270 | }; |
281 | 271 | ||
282 | /** | 272 | /** |
283 | * 根据手机验证码修改密码 | 273 | * 根据手机验证码修改密码 |
284 | */ | 274 | */ |
285 | -module.exports.setNewPasswordByMobileAPI = (req, res) => { | 275 | +const setNewPasswordByMobileAPI = (req, res, next) => { |
286 | let phoneNum = req.body.phoneNum || ''; | 276 | let phoneNum = req.body.phoneNum || ''; |
287 | - | ||
288 | let token = req.body.token || ''; | 277 | let token = req.body.token || ''; |
289 | - | ||
290 | let areaCode = req.body.areaCode || '86'; | 278 | let areaCode = req.body.areaCode || '86'; |
291 | - | ||
292 | let newPwd = req.body.password || ''; | 279 | let newPwd = req.body.password || ''; |
293 | 280 | ||
294 | service.modifyPasswordByMobileAsync(phoneNum, token, newPwd, areaCode) | 281 | service.modifyPasswordByMobileAsync(phoneNum, token, newPwd, areaCode) |
295 | .then(result => { | 282 | .then(result => { |
283 | + console.log(result); | ||
296 | if (result.code === 200) { | 284 | if (result.code === 200) { |
297 | - result.data = SIGN_IN_URL; | 285 | + res.json({ |
286 | + code: 200, | ||
287 | + data: SIGN_IN | ||
288 | + }); | ||
289 | + } else { | ||
290 | + res.json({ | ||
291 | + code : 400, | ||
292 | + message: "修改密码失败" | ||
293 | + }) | ||
298 | } | 294 | } |
295 | + }) | ||
296 | + .catch(next); | ||
297 | +}; | ||
299 | 298 | ||
300 | - res.json(result); | ||
301 | - }).catch(() => res.json({code: 400, message: '修改密码失败'})); | 299 | +module.exports = { |
300 | + indexEmailPage, | ||
301 | + sendCodeToEmailAPI, | ||
302 | + resendCodeToEmailAPI, | ||
303 | + backSuccessByEmailPage, | ||
304 | + setNewPasswordByEmailAPI, | ||
305 | + indexMobilePage, | ||
306 | + sendCodeToMobileAPI, | ||
307 | + verifyCodeByMobilePage, | ||
308 | + verifyCodeByMobileAPI, | ||
309 | + setNewPasswordByMobilePage, | ||
310 | + setNewPasswordByMobileAPI | ||
302 | }; | 311 | }; |
@@ -75,7 +75,7 @@ const bind = { | @@ -75,7 +75,7 @@ const bind = { | ||
75 | }); | 75 | }); |
76 | }, | 76 | }, |
77 | 77 | ||
78 | - bindCheck: (req, res) => { | 78 | + bindCheck: (req, res, next) => { |
79 | let phoneNum = req.body.phoneNum; | 79 | let phoneNum = req.body.phoneNum; |
80 | let openId = req.body.openId; | 80 | let openId = req.body.openId; |
81 | let areaCode = req.body.areaCode || '86'; | 81 | let areaCode = req.body.areaCode || '86'; |
@@ -105,7 +105,7 @@ const bind = { | @@ -105,7 +105,7 @@ const bind = { | ||
105 | } | 105 | } |
106 | 106 | ||
107 | res.json(data); | 107 | res.json(data); |
108 | - }); | 108 | + }).catch(next); |
109 | } else { | 109 | } else { |
110 | res.json({ | 110 | res.json({ |
111 | code: 400, | 111 | code: 400, |
@@ -115,7 +115,7 @@ const bind = { | @@ -115,7 +115,7 @@ const bind = { | ||
115 | } | 115 | } |
116 | }, | 116 | }, |
117 | 117 | ||
118 | - sendBindMsg: (req, res) => { | 118 | + sendBindMsg: (req, res, next) => { |
119 | let phoneNum = req.body.phoneNum; | 119 | let phoneNum = req.body.phoneNum; |
120 | let areaCode = req.body.areaCode; | 120 | let areaCode = req.body.areaCode; |
121 | 121 | ||
@@ -126,13 +126,13 @@ const bind = { | @@ -126,13 +126,13 @@ const bind = { | ||
126 | } else { | 126 | } else { |
127 | res.json({ code: 400, message: '', data: '' }); | 127 | res.json({ code: 400, message: '', data: '' }); |
128 | } | 128 | } |
129 | - }); | 129 | + }).catch(next); |
130 | } else { | 130 | } else { |
131 | res.json({ code: 400, message: '', data: '' }); | 131 | res.json({ code: 400, message: '', data: '' }); |
132 | } | 132 | } |
133 | }, | 133 | }, |
134 | 134 | ||
135 | - checkBindMsg: (req, res) => { | 135 | + checkBindMsg: (req, res, next) => { |
136 | let phoneNum = req.body.phoneNum; | 136 | let phoneNum = req.body.phoneNum; |
137 | let code = req.body.code; | 137 | let code = req.body.code; |
138 | let areaCode = req.body.areaCode; | 138 | let areaCode = req.body.areaCode; |
@@ -144,13 +144,13 @@ const bind = { | @@ -144,13 +144,13 @@ const bind = { | ||
144 | } else { | 144 | } else { |
145 | res.json({ code: 400, message: '', data: '' }); | 145 | res.json({ code: 400, message: '', data: '' }); |
146 | } | 146 | } |
147 | - }); | 147 | + }).catch(next); |
148 | } else { | 148 | } else { |
149 | res.json({ code: 400, message: '', data: '' }); | 149 | res.json({ code: 400, message: '', data: '' }); |
150 | } | 150 | } |
151 | }, | 151 | }, |
152 | 152 | ||
153 | - bindMobile: (req, res) => { | 153 | + bindMobile: (req, res, next) => { |
154 | let phoneNum = req.body.phoneNum; | 154 | let phoneNum = req.body.phoneNum; |
155 | let openId = req.body.openId; | 155 | let openId = req.body.openId; |
156 | let areaCode = req.body.areaCode || '86'; | 156 | let areaCode = req.body.areaCode || '86'; |
@@ -176,13 +176,13 @@ const bind = { | @@ -176,13 +176,13 @@ const bind = { | ||
176 | return result; | 176 | return result; |
177 | }).then(result => { | 177 | }).then(result => { |
178 | res.json(result); | 178 | res.json(result); |
179 | - }); | 179 | + }).catch(next); |
180 | } else { | 180 | } else { |
181 | res.json({ code: 400, message: '', data: '' }); | 181 | res.json({ code: 400, message: '', data: '' }); |
182 | } | 182 | } |
183 | }, | 183 | }, |
184 | 184 | ||
185 | - relateMobile: (req, res) => { | 185 | + relateMobile: (req, res, next) => { |
186 | let phoneNum = req.body.phoneNum; | 186 | let phoneNum = req.body.phoneNum; |
187 | let openId = req.body.openId; | 187 | let openId = req.body.openId; |
188 | let areaCode = req.body.areaCode || '86'; | 188 | let areaCode = req.body.areaCode || '86'; |
@@ -206,7 +206,7 @@ const bind = { | @@ -206,7 +206,7 @@ const bind = { | ||
206 | return result; | 206 | return result; |
207 | }).then(result => { | 207 | }).then(result => { |
208 | res.json(result); | 208 | res.json(result); |
209 | - }); | 209 | + }).catch(next); |
210 | } else { | 210 | } else { |
211 | res.json({ code: 400, message: '', data: '' }); | 211 | res.json({ code: 400, message: '', data: '' }); |
212 | } | 212 | } |
@@ -223,20 +223,20 @@ const bind = { | @@ -223,20 +223,20 @@ const bind = { | ||
223 | }); | 223 | }); |
224 | }, | 224 | }, |
225 | 225 | ||
226 | - changeCheck: (req, res) => { | 226 | + changeCheck: (req, res, next) => { |
227 | let phoneNum = req.body.phoneNum; | 227 | let phoneNum = req.body.phoneNum; |
228 | let areaCode = req.body.areaCode; | 228 | let areaCode = req.body.areaCode; |
229 | 229 | ||
230 | if (_.isNumber(parseInt(phoneNum, 0)) && areaCode) { | 230 | if (_.isNumber(parseInt(phoneNum, 0)) && areaCode) { |
231 | BindService.changeCheck(phoneNum, areaCode).then(result => { | 231 | BindService.changeCheck(phoneNum, areaCode).then(result => { |
232 | res.json(result); | 232 | res.json(result); |
233 | - }); | 233 | + }).catch(next); |
234 | } else { | 234 | } else { |
235 | res.json({ code: 400, message: '', data: '' }); | 235 | res.json({ code: 400, message: '', data: '' }); |
236 | } | 236 | } |
237 | }, | 237 | }, |
238 | 238 | ||
239 | - changeMobile: (req, res) => { | 239 | + changeMobile: (req, res, next) => { |
240 | let uid = req.user.uid; | 240 | let uid = req.user.uid; |
241 | let phoneNum = req.body.phoneNum; | 241 | let phoneNum = req.body.phoneNum; |
242 | let areaCode = req.body.areaCode; | 242 | let areaCode = req.body.areaCode; |
@@ -245,7 +245,7 @@ const bind = { | @@ -245,7 +245,7 @@ const bind = { | ||
245 | if (_.isNumber(parseInt(phoneNum, 0)) && uid && areaCode && code) { | 245 | if (_.isNumber(parseInt(phoneNum, 0)) && uid && areaCode && code) { |
246 | BindService.changeMobile(uid, phoneNum, areaCode, code).then(result => { | 246 | BindService.changeMobile(uid, phoneNum, areaCode, code).then(result => { |
247 | res.json(result); | 247 | res.json(result); |
248 | - }); | 248 | + }).catch(next); |
249 | } else { | 249 | } else { |
250 | res.json({ code: 400, message: '', data: '' }); | 250 | res.json({ code: 400, message: '', data: '' }); |
251 | } | 251 | } |
@@ -14,8 +14,7 @@ const cookie = require(global.library + '/cookie'); | @@ -14,8 +14,7 @@ const cookie = require(global.library + '/cookie'); | ||
14 | const RegService = require('../models/reg-service'); | 14 | const RegService = require('../models/reg-service'); |
15 | const AuthHelper = require('../models/auth-helper'); | 15 | const AuthHelper = require('../models/auth-helper'); |
16 | 16 | ||
17 | -const reg = { | ||
18 | - index: (req, res) => { | 17 | +let index = (req, res) => { |
19 | // 设置注册有效时间30分钟, 防机器刷 | 18 | // 设置注册有效时间30分钟, 防机器刷 |
20 | req.session._REG_EXPIRE = Date.now() + 1800000; | 19 | req.session._REG_EXPIRE = Date.now() + 1800000; |
21 | 20 | ||
@@ -33,8 +32,8 @@ const reg = { | @@ -33,8 +32,8 @@ const reg = { | ||
33 | areaCode: '+86', // 默认的区号 | 32 | areaCode: '+86', // 默认的区号 |
34 | countrys: RegService.getAreaData() // 地区信息列表 | 33 | countrys: RegService.getAreaData() // 地区信息列表 |
35 | }); | 34 | }); |
36 | - }, | ||
37 | - verifyMobile: (req, res, next) => { | 35 | +}; |
36 | +let verifyMobile = (req, res, next) => { | ||
38 | let data = { | 37 | let data = { |
39 | code: 400, | 38 | code: 400, |
40 | message: '手机号已存在', | 39 | message: '手机号已存在', |
@@ -77,8 +76,8 @@ const reg = { | @@ -77,8 +76,8 @@ const reg = { | ||
77 | 76 | ||
78 | return res.json(result); | 77 | return res.json(result); |
79 | }).catch(next); | 78 | }).catch(next); |
80 | - }, | ||
81 | - code: (req, res, next) => { | 79 | +}; |
80 | +let codeAction = (req, res, next) => { | ||
82 | let token = req.query.token; | 81 | let token = req.query.token; |
83 | let mobile = +req.query.phoneNum; | 82 | let mobile = +req.query.phoneNum; |
84 | let area = +(req.query.areaCode || 86); | 83 | let area = +(req.query.areaCode || 86); |
@@ -102,8 +101,8 @@ const reg = { | @@ -102,8 +101,8 @@ const reg = { | ||
102 | token: token, // 访问令牌 | 101 | token: token, // 访问令牌 |
103 | serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=' // 在线客服 | 102 | serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=' // 在线客服 |
104 | }); | 103 | }); |
105 | - }, | ||
106 | - sendCode: (req, res, next) => { | 104 | +}; |
105 | +let sendCode = (req, res, next) => { | ||
107 | let data = { | 106 | let data = { |
108 | code: 400, | 107 | code: 400, |
109 | message: '发送验证码失败', | 108 | message: '发送验证码失败', |
@@ -131,8 +130,8 @@ const reg = { | @@ -131,8 +130,8 @@ const reg = { | ||
131 | RegService.sendCodeToMobile(area, mobile).then((result) => { | 130 | RegService.sendCodeToMobile(area, mobile).then((result) => { |
132 | return result.code ? res.json(result) : res.json(data); | 131 | return result.code ? res.json(result) : res.json(data); |
133 | }).catch(next); | 132 | }).catch(next); |
134 | - }, | ||
135 | - verifyCode: (req, res, next) => { | 133 | +}; |
134 | +let verifyCode = (req, res, next) => { | ||
136 | let data = { | 135 | let data = { |
137 | code: 400, | 136 | code: 400, |
138 | message: '验证码错误', | 137 | message: '验证码错误', |
@@ -178,8 +177,8 @@ const reg = { | @@ -178,8 +177,8 @@ const reg = { | ||
178 | 177 | ||
179 | return res.json(result); | 178 | return res.json(result); |
180 | }).catch(next); | 179 | }).catch(next); |
181 | - }, | ||
182 | - password: (req, res, next) => { | 180 | +}; |
181 | +let passwordAction = (req, res, next) => { | ||
183 | let token = req.query.token; | 182 | let token = req.query.token; |
184 | let mobile = +req.query.phoneNum; | 183 | let mobile = +req.query.phoneNum; |
185 | let area = +(req.query.areaCode || 86); | 184 | let area = +(req.query.areaCode || 86); |
@@ -202,8 +201,8 @@ const reg = { | @@ -202,8 +201,8 @@ const reg = { | ||
202 | phoneNum: mobile, // 手机号 | 201 | phoneNum: mobile, // 手机号 |
203 | token: token // 访问令牌 | 202 | token: token // 访问令牌 |
204 | }); | 203 | }); |
205 | - }, | ||
206 | - setPassword: (req, res, next) => { | 204 | +}; |
205 | +let setPassword = (req, res, next) => { | ||
207 | let data = { | 206 | let data = { |
208 | code: 400, | 207 | code: 400, |
209 | message: '密码格式不正确', | 208 | message: '密码格式不正确', |
@@ -268,7 +267,14 @@ const reg = { | @@ -268,7 +267,14 @@ const reg = { | ||
268 | } | 267 | } |
269 | }); | 268 | }); |
270 | }).catch(next); | 269 | }).catch(next); |
271 | - } | ||
272 | }; | 270 | }; |
273 | 271 | ||
274 | -module.exports = reg; | 272 | +module.exports = { |
273 | + index, | ||
274 | + verifyMobile, | ||
275 | + code: codeAction, | ||
276 | + sendCode, | ||
277 | + verifyCode, | ||
278 | + password: passwordAction, | ||
279 | + setPassword | ||
280 | +}; |
@@ -59,11 +59,11 @@ class Auth { | @@ -59,11 +59,11 @@ class Auth { | ||
59 | domain: 'yohobuy.com' | 59 | domain: 'yohobuy.com' |
60 | }); | 60 | }); |
61 | } | 61 | } |
62 | - req.session._TOKEN = token; // esline-disable-line | ||
63 | - req.session._LOGIN_UID = uid; // esline-disable-line | 62 | + req.session._TOKEN = token; |
63 | + req.session._LOGIN_UID = uid; | ||
64 | res.cookie('_TOKEN', token, { | 64 | res.cookie('_TOKEN', token, { |
65 | domain: 'yohobuy.com' | 65 | domain: 'yohobuy.com' |
66 | - }); // esline-disable-line | 66 | + }); |
67 | }); | 67 | }); |
68 | } | 68 | } |
69 | } | 69 | } |
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | 6 | ||
7 | var API = require('../../../library/api').API; | 7 | var API = require('../../../library/api').API; |
8 | const library = '../../../library'; | 8 | const library = '../../../library'; |
9 | -const sign = require(`${library}/sign`); | ||
10 | 9 | ||
11 | var api = new API(); | 10 | var api = new API(); |
12 | 11 | ||
@@ -15,10 +14,10 @@ const YOHOBUY_URL = 'http://www.yohobuy.com/'; | @@ -15,10 +14,10 @@ const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
15 | /** | 14 | /** |
16 | * 获取地区数据 | 15 | * 获取地区数据 |
17 | */ | 16 | */ |
18 | -module.exports.getAreaDataAsync = () => { | ||
19 | - return api.get('', sign.apiSign({ | 17 | +const getAreaDataAsync = () => { |
18 | + return api.get('', { | ||
20 | method: 'app.passport.getArea' | 19 | method: 'app.passport.getArea' |
21 | - })).then(result => { | 20 | + }).then(result => { |
22 | result.data = result.data.map(value => { | 21 | result.data = result.data.map(value => { |
23 | value.areaCode = `+${value.area}`; | 22 | value.areaCode = `+${value.area}`; |
24 | 23 | ||
@@ -41,11 +40,11 @@ module.exports.getAreaDataAsync = () => { | @@ -41,11 +40,11 @@ module.exports.getAreaDataAsync = () => { | ||
41 | * | 40 | * |
42 | * @param string mail 邮箱地址 | 41 | * @param string mail 邮箱地址 |
43 | */ | 42 | */ |
44 | -module.exports.sendCodeToEmailAsync = (email) => { | ||
45 | - return api.get('', sign.apiSign({ | 43 | +const sendCodeToEmailAsync = (email) => { |
44 | + return api.get('', { | ||
46 | method: 'app.register.backpwdByEmail', | 45 | method: 'app.register.backpwdByEmail', |
47 | - email: email | ||
48 | - })); | 46 | + email : email |
47 | + }); | ||
49 | }; | 48 | }; |
50 | 49 | ||
51 | /** | 50 | /** |
@@ -54,13 +53,13 @@ module.exports.sendCodeToEmailAsync = (email) => { | @@ -54,13 +53,13 @@ module.exports.sendCodeToEmailAsync = (email) => { | ||
54 | * @param string pwd 新密码 | 53 | * @param string pwd 新密码 |
55 | * @param string code 邮箱验证码 | 54 | * @param string code 邮箱验证码 |
56 | */ | 55 | */ |
57 | -module.exports.modifyPasswordByEmailAsync = (pwd, code) => { | 56 | +const modifyPasswordByEmailAsync = (pwd, code) => { |
58 | const options = { | 57 | const options = { |
59 | - url: `${YOHOBUY_URL}passport/back/update`, | ||
60 | - form: { | ||
61 | - pwd: pwd, | 58 | + url : `${YOHOBUY_URL}passport/back/update`, |
59 | + form : { | ||
60 | + pwd : pwd, | ||
62 | 're-input': pwd, | 61 | 're-input': pwd, |
63 | - code: code | 62 | + code : code |
64 | }, | 63 | }, |
65 | timeout: 3000 | 64 | timeout: 3000 |
66 | }; | 65 | }; |
@@ -74,14 +73,12 @@ module.exports.modifyPasswordByEmailAsync = (pwd, code) => { | @@ -74,14 +73,12 @@ module.exports.modifyPasswordByEmailAsync = (pwd, code) => { | ||
74 | * @param string mobile 手机号 | 73 | * @param string mobile 手机号 |
75 | * @param integer area 地区码ID | 74 | * @param integer area 地区码ID |
76 | */ | 75 | */ |
77 | -module.exports.sendCodeToMobileAsync = (mobile, area) => { | ||
78 | - area = area || 86; | ||
79 | - | ||
80 | - return api.get('', sign.apiSign({ | 76 | +const sendCodeToMobileAsync = (mobile, area) => { |
77 | + return api.get('', { | ||
81 | mobile: mobile, | 78 | mobile: mobile, |
82 | - area: area, | 79 | + area : area, |
83 | method: 'app.register.sendBackpwdCodeToMobile' | 80 | method: 'app.register.sendBackpwdCodeToMobile' |
84 | - })); | 81 | + }); |
85 | }; | 82 | }; |
86 | 83 | ||
87 | /** | 84 | /** |
@@ -91,14 +88,14 @@ module.exports.sendCodeToMobileAsync = (mobile, area) => { | @@ -91,14 +88,14 @@ module.exports.sendCodeToMobileAsync = (mobile, area) => { | ||
91 | * @param string code 验证码 | 88 | * @param string code 验证码 |
92 | * @param integer area 地区码ID | 89 | * @param integer area 地区码ID |
93 | */ | 90 | */ |
94 | -module.exports.validateMobileCodeAsync = (mobile, code, area) => { | 91 | +const validateMobileCodeAsync = (mobile, code, area) => { |
95 | area = area || 86; | 92 | area = area || 86; |
96 | - return api.get('', sign.apiSign({ | 93 | + return api.get('', { |
97 | mobile: mobile, | 94 | mobile: mobile, |
98 | - code: code, | ||
99 | - area: area, | 95 | + code : code, |
96 | + area : area, | ||
100 | method: 'app.register.validBackpwdCode' | 97 | method: 'app.register.validBackpwdCode' |
101 | - })); | 98 | + }); |
102 | }; | 99 | }; |
103 | 100 | ||
104 | /** | 101 | /** |
@@ -108,15 +105,22 @@ module.exports.validateMobileCodeAsync = (mobile, code, area) => { | @@ -108,15 +105,22 @@ module.exports.validateMobileCodeAsync = (mobile, code, area) => { | ||
108 | * @param string token 验证手机验证码返回的token | 105 | * @param string token 验证手机验证码返回的token |
109 | * @param integer area 地区码ID | 106 | * @param integer area 地区码ID |
110 | */ | 107 | */ |
111 | -module.exports.modifyPasswordByMobileAsync = (mobile, token, newpwd, area)=> { | ||
112 | - area = area || 86; | ||
113 | - return api.get('', sign.apiSign({ | 108 | +const modifyPasswordByMobileAsync = (mobile, token, newpwd, area)=> { |
109 | + return api.get('', { | ||
114 | mobile: mobile, | 110 | mobile: mobile, |
115 | - token: token, | 111 | + token : token, |
116 | newpwd: newpwd, | 112 | newpwd: newpwd, |
117 | - area: area, | 113 | + area : area, |
118 | method: 'app.register.changepwdByMobileCode' | 114 | method: 'app.register.changepwdByMobileCode' |
119 | - })); | 115 | + }); |
120 | }; | 116 | }; |
121 | 117 | ||
118 | +module.exports = { | ||
119 | + getAreaDataAsync, | ||
120 | + sendCodeToEmailAsync, | ||
121 | + modifyPasswordByEmailAsync, | ||
122 | + sendCodeToMobileAsync, | ||
123 | + validateMobileCodeAsync, | ||
124 | + modifyPasswordByMobileAsync | ||
125 | +}; | ||
122 | 126 |
@@ -10,9 +10,8 @@ | @@ -10,9 +10,8 @@ | ||
10 | const API = require(`${global.library}/api`).API; | 10 | const API = require(`${global.library}/api`).API; |
11 | const api = new API(); | 11 | const api = new API(); |
12 | 12 | ||
13 | -class RegService { | ||
14 | - | ||
15 | - static bindCheck(mobile, openId, sourceType, area) { | 13 | +const RegService = { |
14 | + bindCheck(mobile, openId, sourceType, area) { | ||
16 | let params = { | 15 | let params = { |
17 | method: 'app.passport.signCheck', | 16 | method: 'app.passport.signCheck', |
18 | area: area, | 17 | area: area, |
@@ -22,9 +21,8 @@ class RegService { | @@ -22,9 +21,8 @@ class RegService { | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | return api.get('', params); | 23 | return api.get('', params); |
25 | - } | ||
26 | - | ||
27 | - static sendBindMsg(area, mobile) { | 24 | + }, |
25 | + sendBindMsg(area, mobile) { | ||
28 | let params = { | 26 | let params = { |
29 | method: 'app.passport.smsbind', | 27 | method: 'app.passport.smsbind', |
30 | mobile: mobile, | 28 | mobile: mobile, |
@@ -32,18 +30,16 @@ class RegService { | @@ -32,18 +30,16 @@ class RegService { | ||
32 | }; | 30 | }; |
33 | 31 | ||
34 | return api.get('', params); | 32 | return api.get('', params); |
35 | - } | ||
36 | - | ||
37 | - static checkBindCode(area, mobile, code) { | 33 | + }, |
34 | + checkBindCode(area, mobile, code) { | ||
38 | return api.get('', { | 35 | return api.get('', { |
39 | method: 'app.register.validRegCode', | 36 | method: 'app.register.validRegCode', |
40 | mobile: mobile, | 37 | mobile: mobile, |
41 | area: area, | 38 | area: area, |
42 | code: code | 39 | code: code |
43 | }); | 40 | }); |
44 | - } | ||
45 | - | ||
46 | - static bindMobile(openId, sourceType, mobile, area, password, nickname) { | 41 | + }, |
42 | + bindMobile(openId, sourceType, mobile, area, password, nickname) { | ||
47 | let params = { | 43 | let params = { |
48 | method: 'app.passport.bind', | 44 | method: 'app.passport.bind', |
49 | mobile: mobile, | 45 | mobile: mobile, |
@@ -61,9 +57,8 @@ class RegService { | @@ -61,9 +57,8 @@ class RegService { | ||
61 | } | 57 | } |
62 | 58 | ||
63 | return api.get('', params); | 59 | return api.get('', params); |
64 | - } | ||
65 | - | ||
66 | - static relateMobile(openId, sourceType, mobile, area) { | 60 | + }, |
61 | + relateMobile(openId, sourceType, mobile, area) { | ||
67 | return api.get('', { | 62 | return api.get('', { |
68 | method: 'app.passport.relateMobile', | 63 | method: 'app.passport.relateMobile', |
69 | mobile: mobile, | 64 | mobile: mobile, |
@@ -71,17 +66,15 @@ class RegService { | @@ -71,17 +66,15 @@ class RegService { | ||
71 | source_type: sourceType, | 66 | source_type: sourceType, |
72 | area: area | 67 | area: area |
73 | }); | 68 | }); |
74 | - } | ||
75 | - | ||
76 | - static changeCheck(mobile, area) { | 69 | + }, |
70 | + changeCheck(mobile, area) { | ||
77 | return api.get('', { | 71 | return api.get('', { |
78 | method: 'app.passport.changeCheck', | 72 | method: 'app.passport.changeCheck', |
79 | mobile: mobile, | 73 | mobile: mobile, |
80 | area: area | 74 | area: area |
81 | }); | 75 | }); |
82 | - } | ||
83 | - | ||
84 | - static changeMobile(uid, mobile, area, code) { | 76 | + }, |
77 | + changeMobile(uid, mobile, area, code) { | ||
85 | return api.get('', { | 78 | return api.get('', { |
86 | method: 'app.passport.changeMobile', | 79 | method: 'app.passport.changeMobile', |
87 | mobile: mobile, | 80 | mobile: mobile, |
@@ -90,6 +83,6 @@ class RegService { | @@ -90,6 +83,6 @@ class RegService { | ||
90 | area: area | 83 | area: area |
91 | }); | 84 | }); |
92 | } | 85 | } |
93 | -} | 86 | +}; |
94 | 87 | ||
95 | module.exports = RegService; | 88 | module.exports = RegService; |
@@ -16,7 +16,7 @@ const ALIPAY_URL = 'https://mapi.alipay.com/gateway.do'; | @@ -16,7 +16,7 @@ const ALIPAY_URL = 'https://mapi.alipay.com/gateway.do'; | ||
16 | 16 | ||
17 | const defaultOptions = { | 17 | const defaultOptions = { |
18 | service: 'alipay.auth.authorize', | 18 | service: 'alipay.auth.authorize', |
19 | - _input_charset: 'utf-8', // esline-disable-line | 19 | + _input_charset: 'utf-8', |
20 | sign_type: 'MD5', | 20 | sign_type: 'MD5', |
21 | target_service: 'user.auth.quick.login' | 21 | target_service: 'user.auth.quick.login' |
22 | }; | 22 | }; |
@@ -10,9 +10,8 @@ | @@ -10,9 +10,8 @@ | ||
10 | const API = require(`${global.library}/api`).API; | 10 | const API = require(`${global.library}/api`).API; |
11 | const api = new API(); | 11 | const api = new API(); |
12 | 12 | ||
13 | -class RegService { | ||
14 | - | ||
15 | - static getAreaData() { | 13 | +const RegService = { |
14 | + getAreaData() { | ||
16 | return [ | 15 | return [ |
17 | { | 16 | { |
18 | areaCode: '+61', | 17 | areaCode: '+61', |
@@ -63,9 +62,8 @@ class RegService { | @@ -63,9 +62,8 @@ class RegService { | ||
63 | selected: false, | 62 | selected: false, |
64 | name: '中国香港' | 63 | name: '中国香港' |
65 | }]; | 64 | }]; |
66 | - } | ||
67 | - | ||
68 | - static sendCodeToMobile(area, mobile) { | 65 | + }, |
66 | + sendCodeToMobile(area, mobile) { | ||
69 | let params = { | 67 | let params = { |
70 | method: 'app.register.sendRegCodeToMobile', | 68 | method: 'app.register.sendRegCodeToMobile', |
71 | area: area, | 69 | area: area, |
@@ -73,9 +71,8 @@ class RegService { | @@ -73,9 +71,8 @@ class RegService { | ||
73 | }; | 71 | }; |
74 | 72 | ||
75 | return api.post('', params); | 73 | return api.post('', params); |
76 | - } | ||
77 | - | ||
78 | - static validMobileCode(area, mobile, code) { | 74 | + }, |
75 | + validMobileCode(area, mobile, code) { | ||
79 | let params = { | 76 | let params = { |
80 | method: 'app.register.validRegCode', | 77 | method: 'app.register.validRegCode', |
81 | area: area, | 78 | area: area, |
@@ -84,9 +81,8 @@ class RegService { | @@ -84,9 +81,8 @@ class RegService { | ||
84 | }; | 81 | }; |
85 | 82 | ||
86 | return api.post('', params); | 83 | return api.post('', params); |
87 | - } | ||
88 | - | ||
89 | - static regMobile(area, mobile, password, shoppingKey) { | 84 | + }, |
85 | + regMobile(area, mobile, password, shoppingKey) { | ||
90 | let params = { | 86 | let params = { |
91 | method: 'app.passport.register', | 87 | method: 'app.passport.register', |
92 | area: area, | 88 | area: area, |
@@ -95,11 +91,11 @@ class RegService { | @@ -95,11 +91,11 @@ class RegService { | ||
95 | }; | 91 | }; |
96 | 92 | ||
97 | if (shoppingKey) { | 93 | if (shoppingKey) { |
98 | - params.shopping_key = shoppingKey; // esline-disable-line | 94 | + params.shopping_key = shoppingKey; |
99 | } | 95 | } |
100 | 96 | ||
101 | return api.post('', params); | 97 | return api.post('', params); |
102 | } | 98 | } |
103 | -} | 99 | +}; |
104 | 100 | ||
105 | module.exports = RegService; | 101 | module.exports = RegService; |
@@ -13,6 +13,7 @@ const back = require(cRoot + '/back'); | @@ -13,6 +13,7 @@ const back = require(cRoot + '/back'); | ||
13 | const bind = require(cRoot + '/bind'); | 13 | const bind = require(cRoot + '/bind'); |
14 | const reg = require(cRoot + '/reg'); | 14 | const reg = require(cRoot + '/reg'); |
15 | 15 | ||
16 | + | ||
16 | const router = express.Router(); // eslint-disable-line | 17 | const router = express.Router(); // eslint-disable-line |
17 | 18 | ||
18 | // 登出 | 19 | // 登出 |
@@ -61,44 +62,20 @@ router.get('/reg/password', reg.password); | @@ -61,44 +62,20 @@ router.get('/reg/password', reg.password); | ||
61 | router.post('/reg/setpassword', reg.setPassword); | 62 | router.post('/reg/setpassword', reg.setPassword); |
62 | 63 | ||
63 | /** | 64 | /** |
64 | - * 邮箱 | 65 | + * 密码找回 |
65 | */ | 66 | */ |
66 | - | ||
67 | -// 通过邮箱找回密码 | ||
68 | -router.get('/back/email.html', back.indexByEmailPage); | ||
69 | - | ||
70 | -// 邮箱找回密码-成功 | ||
71 | -router.get('/back/success.html', back.backSuccessByEmailPage); | ||
72 | - | ||
73 | -// 发送邮箱验证码 | ||
74 | -router.post('/back/sendemail', back.sendCodeToEmailAPI); | ||
75 | - | ||
76 | -// 重新发送邮箱验证码 | ||
77 | -router.get('/back/resendemail', back.resendCodeToEmailAPI); | ||
78 | - | ||
79 | -// 据邮箱修改密码 | ||
80 | -router.post('/back/passwordbyemail', back.setNewPasswordByEmailAPI); | ||
81 | - | ||
82 | -/** | ||
83 | - * 手机 | ||
84 | - */ | ||
85 | - | ||
86 | -// 通过手机找回密码 | ||
87 | -router.get('/back/mobile.html', back.indexByMobilePage); | ||
88 | - | ||
89 | -// 发送手机验证码 | ||
90 | -router.get('/back/mobilecode.html', back.verifyCodeByMobilePage); | ||
91 | - | ||
92 | -// 输入新密码 | ||
93 | -router.get('/back/backcode.html', back.setNewPasswordByMobilePage); | ||
94 | - | ||
95 | -// 发送手机验证码 | ||
96 | -router.post('/back/sendcode', back.sendCodeToMobileAPI); | ||
97 | - | ||
98 | -// 校验手机验证码 | ||
99 | -router.post('/back/verifycode', back.verifyCodeByMobileAPI); | ||
100 | - | ||
101 | -// 根据手机验证码修改密码 | ||
102 | -router.post('/back/passwordbymobile', back.setNewPasswordByMobileAPI); | 67 | +router.get('/back/email', back.indexEmailPage);// 通过邮箱找回密码页面 |
68 | +router.post('/back/sendemail', back.sendCodeToEmailAPI);// 发送邮箱验证码 | ||
69 | +router.get('/back/resendemail', back.resendCodeToEmailAPI);// 重新发送邮箱验证码 | ||
70 | +router.get('/back/success', back.backSuccessByEmailPage);// 邮箱找回密码-发送成功页面 | ||
71 | + | ||
72 | +router.get('/back/mobile', back.indexMobilePage);// 输入手机号找回密码页面 | ||
73 | +router.get('/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面 | ||
74 | +router.post('/back/sendcode', back.sendCodeToMobileAPI);// 发送手机验证码 | ||
75 | +router.post('/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码 | ||
76 | + | ||
77 | +router.get('/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面 | ||
78 | +router.post('/back/passwordbyemail', back.setNewPasswordByEmailAPI);// 依据邮箱验证码修改密码 | ||
79 | +router.post('/back/passwordbymobile', back.setNewPasswordByMobileAPI);// 依据手机验证码修改密码 | ||
103 | 80 | ||
104 | module.exports = router; | 81 | module.exports = router; |
@@ -286,6 +286,9 @@ exports.verifyMobile = (phone) => { | @@ -286,6 +286,9 @@ exports.verifyMobile = (phone) => { | ||
286 | return /^1[3|4|5|8|7][0-9]{9}$/.test(phone); | 286 | return /^1[3|4|5|8|7][0-9]{9}$/.test(phone); |
287 | }; | 287 | }; |
288 | 288 | ||
289 | +/** | ||
290 | + * 验证密码规则 | ||
291 | + */ | ||
289 | exports.verifyPassword = (password) => { | 292 | exports.verifyPassword = (password) => { |
290 | if (!password) { | 293 | if (!password) { |
291 | return false; | 294 | return false; |
This diff could not be displayed because it is too large.
@@ -49,7 +49,7 @@ $btnOk.on('touchstart', function() { | @@ -49,7 +49,7 @@ $btnOk.on('touchstart', function() { | ||
49 | if (mobileBack) { | 49 | if (mobileBack) { |
50 | $.extend(setting, { | 50 | $.extend(setting, { |
51 | phoneNum: $phoneNum.val(), | 51 | phoneNum: $phoneNum.val(), |
52 | - areaCode: $('#areaCode').val(), | 52 | + areaCode: $('#area-code').val(), |
53 | token: $('#token').val() | 53 | token: $('#token').val() |
54 | }); | 54 | }); |
55 | 55 |
@@ -20,7 +20,7 @@ var tip = require('../../plugin/tip'); | @@ -20,7 +20,7 @@ var tip = require('../../plugin/tip'); | ||
20 | var trim = $.trim; | 20 | var trim = $.trim; |
21 | var showErrTip = tip.show; | 21 | var showErrTip = tip.show; |
22 | 22 | ||
23 | -//登录按钮状态切换 | 23 | +// 登录按钮状态切换 |
24 | function switchLoginBtnStatus() { | 24 | function switchLoginBtnStatus() { |
25 | if (pnPass && pwdPass) { | 25 | if (pnPass && pwdPass) { |
26 | $loginBtn.removeClass('disable'); | 26 | $loginBtn.removeClass('disable'); |
@@ -29,13 +29,13 @@ function switchLoginBtnStatus() { | @@ -29,13 +29,13 @@ function switchLoginBtnStatus() { | ||
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | -//Android-UC下显示select的direction:rtl无效的临时解决办法 | 32 | +// Android-UC下显示select的direction:rtl无效的临时解决办法 |
33 | api.selectCssHack($countrySelect); | 33 | api.selectCssHack($countrySelect); |
34 | 34 | ||
35 | -//显示隐藏密码 | 35 | +// 显示隐藏密码 |
36 | api.bindEyesEvt(); | 36 | api.bindEyesEvt(); |
37 | 37 | ||
38 | -//清空手机号码 | 38 | +// 清空手机号码 |
39 | api.bindClearEvt(); | 39 | api.bindClearEvt(); |
40 | 40 | ||
41 | $phoneNum.bind('input', function() { | 41 | $phoneNum.bind('input', function() { |
@@ -98,14 +98,14 @@ $loginBtn.on('touchstart', function() { | @@ -98,14 +98,14 @@ $loginBtn.on('touchstart', function() { | ||
98 | success: function() { | 98 | success: function() { |
99 | clearTimeout(time); | 99 | clearTimeout(time); |
100 | 100 | ||
101 | - //Cookie写入成功后,1s后跳转页面 | 101 | + // Cookie写入成功后,1s后跳转页面 |
102 | setTimeout(function() { | 102 | setTimeout(function() { |
103 | location.href = res.href; | 103 | location.href = res.href; |
104 | }, 1000); | 104 | }, 1000); |
105 | } | 105 | } |
106 | }); | 106 | }); |
107 | 107 | ||
108 | - //3秒后强制跳转 | 108 | + // 3秒后强制跳转 |
109 | time = setTimeout(function() { | 109 | time = setTimeout(function() { |
110 | location.href = res.href; | 110 | location.href = res.href; |
111 | }, 3000); | 111 | }, 3000); |
@@ -128,6 +128,6 @@ $loginBtn.on('touchstart', function() { | @@ -128,6 +128,6 @@ $loginBtn.on('touchstart', function() { | ||
128 | } | 128 | } |
129 | }); | 129 | }); |
130 | 130 | ||
131 | -//对初始有默认值的情况去初始化登录按钮状态 | 131 | +// 对初始有默认值的情况去初始化登录按钮状态 |
132 | $phoneNum.trigger('input'); | 132 | $phoneNum.trigger('input'); |
133 | $pwd.trigger('input'); | 133 | $pwd.trigger('input'); |
@@ -21,7 +21,7 @@ var tip = require('../../plugin/tip'); | @@ -21,7 +21,7 @@ var tip = require('../../plugin/tip'); | ||
21 | var trim = $.trim; | 21 | var trim = $.trim; |
22 | var showErrTip = tip.show; | 22 | var showErrTip = tip.show; |
23 | 23 | ||
24 | -//登录按钮状态切换 | 24 | +// 登录按钮状态切换 |
25 | function switchLoginBtnStatus() { | 25 | function switchLoginBtnStatus() { |
26 | if (accPass && pwdPass) { | 26 | if (accPass && pwdPass) { |
27 | $loginBtn.removeClass('disable'); | 27 | $loginBtn.removeClass('disable'); |
@@ -30,22 +30,22 @@ function switchLoginBtnStatus() { | @@ -30,22 +30,22 @@ function switchLoginBtnStatus() { | ||
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | -//显示找回密码面板 | 33 | +// 显示找回密码面板 |
34 | function showRetrivePanel() { | 34 | function showRetrivePanel() { |
35 | $mask.show(); | 35 | $mask.show(); |
36 | $ways.show(); | 36 | $ways.show(); |
37 | } | 37 | } |
38 | 38 | ||
39 | -//隐藏找回密码面板 | 39 | +// 隐藏找回密码面板 |
40 | function hideRetrivePanel() { | 40 | function hideRetrivePanel() { |
41 | $mask.hide(); | 41 | $mask.hide(); |
42 | $ways.hide(); | 42 | $ways.hide(); |
43 | } | 43 | } |
44 | 44 | ||
45 | -//密码显示与隐藏 | 45 | +// 密码显示与隐藏 |
46 | api.bindEyesEvt(); | 46 | api.bindEyesEvt(); |
47 | 47 | ||
48 | -//清空账号输入框 | 48 | +// 清空账号输入框 |
49 | api.bindClearEvt(); | 49 | api.bindClearEvt(); |
50 | 50 | ||
51 | $account.bind('input', function() { | 51 | $account.bind('input', function() { |
@@ -78,7 +78,7 @@ $loginBtn.on('touchstart', function() { | @@ -78,7 +78,7 @@ $loginBtn.on('touchstart', function() { | ||
78 | 78 | ||
79 | $loginBtn.text('正在登录...').addClass('disable'); | 79 | $loginBtn.text('正在登录...').addClass('disable'); |
80 | 80 | ||
81 | - //验证账号(数字或者邮箱)和密码合理性 | 81 | + // 验证账号(数字或者邮箱)和密码合理性 |
82 | if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { | 82 | if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { |
83 | $.ajax({ | 83 | $.ajax({ |
84 | type: 'POST', | 84 | type: 'POST', |
@@ -126,6 +126,6 @@ $('#cancel-retrive').on('touchstart', function(e) { | @@ -126,6 +126,6 @@ $('#cancel-retrive').on('touchstart', function(e) { | ||
126 | hideRetrivePanel(); | 126 | hideRetrivePanel(); |
127 | }); | 127 | }); |
128 | 128 | ||
129 | -//对初始有默认值的情况去初始化登录按钮状态 | 129 | +// 对初始有默认值的情况去初始化登录按钮状态 |
130 | $account.trigger('input'); | 130 | $account.trigger('input'); |
131 | $pwd.trigger('input'); | 131 | $pwd.trigger('input'); |
-
Please register or login to post a comment