Showing
7 changed files
with
33 additions
and
13 deletions
@@ -56,7 +56,7 @@ passport.use(new LocalStrategy({ | @@ -56,7 +56,7 @@ passport.use(new LocalStrategy({ | ||
56 | 56 | ||
57 | let shoppingKey = cookie.getShoppingKey(req); | 57 | let shoppingKey = cookie.getShoppingKey(req); |
58 | 58 | ||
59 | - AuthHelper.signin(area, username, password, shoppingKey).then((result) => { | 59 | + AuthHelper.signinAes(area, username, password, shoppingKey).then((result) => { |
60 | if (result.code && result.code === 200 && result.data.uid) { | 60 | if (result.code && result.code === 200 && result.data.uid) { |
61 | done(null, result.data); | 61 | done(null, result.data); |
62 | } else { | 62 | } else { |
@@ -120,7 +120,7 @@ const setNewPasswordByEmailAPI = (req, res) => { | @@ -120,7 +120,7 @@ const setNewPasswordByEmailAPI = (req, res) => { | ||
120 | data: SIGN_IN | 120 | data: SIGN_IN |
121 | }; | 121 | }; |
122 | 122 | ||
123 | - service.modifyPasswordByEmailAsync(pwd, code) | 123 | + service.modifyPasswordByEmailAsyncAes(pwd, code) |
124 | .then(result => { | 124 | .then(result => { |
125 | if (result.includes('history.back')) { | 125 | if (result.includes('history.back')) { |
126 | data.code = 400; | 126 | data.code = 400; |
@@ -281,7 +281,7 @@ const setNewPasswordByMobileAPI = (req, res, next) => { | @@ -281,7 +281,7 @@ const setNewPasswordByMobileAPI = (req, res, next) => { | ||
281 | let areaCode = req.body.areaCode || '86'; | 281 | let areaCode = req.body.areaCode || '86'; |
282 | let newPwd = req.body.password || ''; | 282 | let newPwd = req.body.password || ''; |
283 | 283 | ||
284 | - service.modifyPasswordByMobileAsync(phoneNum, token, newPwd, areaCode) | 284 | + service.modifyPasswordByMobileAsyncAes(phoneNum, token, newPwd, areaCode) |
285 | .then(result => { | 285 | .then(result => { |
286 | if (result.code === 200) { | 286 | if (result.code === 200) { |
287 | res.json({ | 287 | res.json({ |
@@ -168,12 +168,16 @@ const bind = { | @@ -168,12 +168,16 @@ const bind = { | ||
168 | }).then(result => { | 168 | }).then(result => { |
169 | let refer = req.cookies.refer; | 169 | let refer = req.cookies.refer; |
170 | 170 | ||
171 | - refer = refer ? decodeURI(refer) : helpers.urlFormat('/passport/bind/success'); | 171 | + refer = refer ? decodeURI(refer) : helpers.urlFormat('/passport/bind/success?type=bind'); |
172 | if (result && result.code && result.code === 200 && result.data.uid) { | 172 | if (result && result.code && result.code === 200 && result.data.uid) { |
173 | - AuthHelper.syncUserSession(result.data.uid, req, res); | ||
174 | - result.data.refer = refer; | 173 | + return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => { |
174 | + result.data.refer = refer; | ||
175 | + return result; | ||
176 | + }); | ||
177 | + } else { | ||
178 | + return { code: 400, message: '绑定失败', data: '' }; | ||
175 | } | 179 | } |
176 | - return result; | 180 | + |
177 | }).then(result => { | 181 | }).then(result => { |
178 | res.json(result); | 182 | res.json(result); |
179 | }).catch(next); | 183 | }).catch(next); |
@@ -205,7 +209,7 @@ const bind = { | @@ -205,7 +209,7 @@ const bind = { | ||
205 | return result; | 209 | return result; |
206 | }); | 210 | }); |
207 | } else { | 211 | } else { |
208 | - return { code: 400, message: '绑定失败', data: '' }; | 212 | + return { code: 400, message: '关联失败', data: '' }; |
209 | } | 213 | } |
210 | 214 | ||
211 | }).then(result => { | 215 | }).then(result => { |
@@ -240,12 +244,13 @@ const bind = { | @@ -240,12 +244,13 @@ const bind = { | ||
240 | 244 | ||
241 | successPage: (req, res) => { | 245 | successPage: (req, res) => { |
242 | let refer = req.cookies.refer; | 246 | let refer = req.cookies.refer; |
247 | + let type = req.query.type; | ||
243 | 248 | ||
244 | refer = refer ? decodeURI(refer) : helpers.urlFormat('/?go=1'); | 249 | refer = refer ? decodeURI(refer) : helpers.urlFormat('/?go=1'); |
245 | 250 | ||
246 | res.render('bind/success', { | 251 | res.render('bind/success', { |
247 | isPassportPage: true, | 252 | isPassportPage: true, |
248 | - successTip: '恭喜您,第三方账号关联手机号码成功!', | 253 | + successTip: type === 'bind' ? '恭喜您,第三方账号绑定手机号码成功!' : '恭喜您,第三方账号关联手机号码成功!', |
249 | goUrl: refer, | 254 | goUrl: refer, |
250 | module: 'passport', | 255 | module: 'passport', |
251 | page: 'bind-success', | 256 | page: 'bind-success', |
@@ -235,7 +235,7 @@ let setPassword = (req, res, next) => { | @@ -235,7 +235,7 @@ let setPassword = (req, res, next) => { | ||
235 | let shoppingKey = cookie.getShoppingKey(req); | 235 | let shoppingKey = cookie.getShoppingKey(req); |
236 | 236 | ||
237 | // 验证注册的标识码是否有效 | 237 | // 验证注册的标识码是否有效 |
238 | - RegService.regMobile(area, mobile, password, shoppingKey).then((result) => { | 238 | + RegService.regMobileAes(area, mobile, password, shoppingKey).then((result) => { |
239 | if (!result.code || result.code !== 200) { | 239 | if (!result.code || result.code !== 200) { |
240 | return Promise.reject(result); | 240 | return Promise.reject(result); |
241 | } | 241 | } |
@@ -67,6 +67,20 @@ const modifyPasswordByEmailAsync = (pwd, code) => { | @@ -67,6 +67,20 @@ const modifyPasswordByEmailAsync = (pwd, code) => { | ||
67 | }; | 67 | }; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | + * 根据邮箱验证码修改密码(调用新接口 采用AES密码加密) | ||
71 | + * | ||
72 | + * @param string pwd 新密码 | ||
73 | + * @param string code 邮箱验证码 | ||
74 | + */ | ||
75 | +const modifyPasswordByEmailAsyncAes = (pwd, code) => { | ||
76 | + return api.get('', { | ||
77 | + code: code, | ||
78 | + newPwd: aes.aesPwd(pwd), | ||
79 | + method: 'app.register.resetPwdByCodeAES' | ||
80 | + }); | ||
81 | +}; | ||
82 | + | ||
83 | +/** | ||
70 | * 通过手机找回密码 | 84 | * 通过手机找回密码 |
71 | * | 85 | * |
72 | * @param string mobile 手机号 | 86 | * @param string mobile 手机号 |
@@ -128,8 +142,10 @@ module.exports = { | @@ -128,8 +142,10 @@ module.exports = { | ||
128 | getAreaDataAsync, | 142 | getAreaDataAsync, |
129 | sendCodeToEmailAsync, | 143 | sendCodeToEmailAsync, |
130 | modifyPasswordByEmailAsync, | 144 | modifyPasswordByEmailAsync, |
145 | + modifyPasswordByEmailAsyncAes, | ||
131 | sendCodeToMobileAsync, | 146 | sendCodeToMobileAsync, |
132 | validateMobileCodeAsync, | 147 | validateMobileCodeAsync, |
133 | - modifyPasswordByMobileAsync | 148 | + modifyPasswordByMobileAsync, |
149 | + modifyPasswordByMobileAsyncAes | ||
134 | }; | 150 | }; |
135 | 151 |
@@ -97,7 +97,6 @@ AlipayStrategy.prototype.authenticate = function(req, options) { | @@ -97,7 +97,6 @@ AlipayStrategy.prototype.authenticate = function(req, options) { | ||
97 | params.sign_type = 'MD5'; | 97 | params.sign_type = 'MD5'; |
98 | } | 98 | } |
99 | 99 | ||
100 | - console.log(paramsToRaw(params)); | ||
101 | this.redirect(ALIPAY_URL + '?' + paramsToRaw(params)); | 100 | this.redirect(ALIPAY_URL + '?' + paramsToRaw(params)); |
102 | } | 101 | } |
103 | }; | 102 | }; |
@@ -96,7 +96,7 @@ const RegService = { | @@ -96,7 +96,7 @@ const RegService = { | ||
96 | 96 | ||
97 | return api.post('', params); | 97 | return api.post('', params); |
98 | }, | 98 | }, |
99 | - regMobileEas(area, mobile, password, shoppingKey) { | 99 | + regMobileAes(area, mobile, password, shoppingKey) { |
100 | let params = { | 100 | let params = { |
101 | method: 'app.passport.registerAES', | 101 | method: 'app.passport.registerAES', |
102 | area: area, | 102 | area: area, |
-
Please register or login to post a comment