Showing
5 changed files
with
33 additions
and
4 deletions
@@ -176,6 +176,7 @@ try { | @@ -176,6 +176,7 @@ try { | ||
176 | const layoutTools = require('./doraemon/middleware/layout-tools'); | 176 | const layoutTools = require('./doraemon/middleware/layout-tools'); |
177 | const pageCache = require('./doraemon/middleware/page-cache'); | 177 | const pageCache = require('./doraemon/middleware/page-cache'); |
178 | const devtool = require('./doraemon/middleware/devtools'); | 178 | const devtool = require('./doraemon/middleware/devtools'); |
179 | + const weakPassCheck = require('./doraemon/middleware/weak-pass-check'); | ||
179 | 180 | ||
180 | // YOHO 前置中间件 | 181 | // YOHO 前置中间件 |
181 | app.use(setYohoData()); | 182 | app.use(setYohoData()); |
@@ -193,6 +194,8 @@ try { | @@ -193,6 +194,8 @@ try { | ||
193 | app.use(devtool()); | 194 | app.use(devtool()); |
194 | } | 195 | } |
195 | 196 | ||
197 | + app.use(weakPassCheck()); | ||
198 | + | ||
196 | require('./dispatch')(app); | 199 | require('./dispatch')(app); |
197 | 200 | ||
198 | app.all('*', errorHanlder.notFound()); // 404 | 201 | app.all('*', errorHanlder.notFound()); // 404 |
@@ -432,7 +432,8 @@ const weakPasswordPage = (req, res, next) => { | @@ -432,7 +432,8 @@ const weakPasswordPage = (req, res, next) => { | ||
432 | resetPwd: { | 432 | resetPwd: { |
433 | coverHref: result.url, | 433 | coverHref: result.url, |
434 | coverImg: result.img, | 434 | coverImg: result.img, |
435 | - refer: refer | 435 | + refer: refer, |
436 | + isCanSkip: req.cookies.canSkip === 'Y' | ||
436 | } | 437 | } |
437 | })); | 438 | })); |
438 | }).catch(next); | 439 | }).catch(next); |
@@ -166,7 +166,6 @@ const local = { | @@ -166,7 +166,6 @@ const local = { | ||
166 | }, | 166 | }, |
167 | login: (req, res, next) => { | 167 | login: (req, res, next) => { |
168 | passport.authenticate('local', (err, user) => { | 168 | passport.authenticate('local', (err, user) => { |
169 | - console.log(err, user, ' === '); | ||
170 | if (err) { | 169 | if (err) { |
171 | return res.json({ | 170 | return res.json({ |
172 | code: 400, | 171 | code: 400, |
@@ -202,7 +201,7 @@ const local = { | @@ -202,7 +201,7 @@ const local = { | ||
202 | loginService.syncUserSession(user, req, res).then((noCertTip) => { | 201 | loginService.syncUserSession(user, req, res).then((noCertTip) => { |
203 | // 弱密码 | 202 | // 弱密码 |
204 | if (user.code === 510) { | 203 | if (user.code === 510) { |
205 | - refer = `${config.siteUrl}/passport/back/weak?token=${user.token}&refer=${refer}`; | 204 | + refer = `${config.siteUrl}/passport/back/weak?refer=${refer}`; |
206 | } else if (noCertTip === true) { | 205 | } else if (noCertTip === true) { |
207 | refer = `${config.siteUrl}/passport/cert/tip?refer=${refer}`; | 206 | refer = `${config.siteUrl}/passport/cert/tip?refer=${refer}`; |
208 | } | 207 | } |
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | <input id="reset-pwd-btn" class="btn reset-pwd-btn disable" type="button" value="重新登录" disabled="true"> | 41 | <input id="reset-pwd-btn" class="btn reset-pwd-btn disable" type="button" value="重新登录" disabled="true"> |
42 | </li> | 42 | </li> |
43 | <li class="input-container-li"> | 43 | <li class="input-container-li"> |
44 | - <a class="weak-pwd-pass" href="{{refer}}" data-url="{{refer}}">跳过<i class="iconfont right-icon"></i></a> | 44 | + <a class="weak-pwd-pass {{#unless isCanSkip}} hide{{/unless}}" href="{{refer}}" data-url="{{refer}}">跳过<i class="iconfont right-icon"></i></a> |
45 | </li> | 45 | </li> |
46 | </ul> | 46 | </ul> |
47 | </form> | 47 | </form> |
doraemon/middleware/weak-pass-check.js
0 → 100644
1 | +/** | ||
2 | + * 弱密码检测 | ||
3 | + * @author: xiaoxiao.hao<xiaoxiao.hao@yoho.cn> | ||
4 | + * @date: 2017/4/17 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const helpers = global.yoho.helpers; | ||
10 | + | ||
11 | +module.exports = () => { | ||
12 | + return (req, res, next) => { | ||
13 | + let refer = req.method === 'GET' ? req.get('Referer') : ''; | ||
14 | + | ||
15 | + refer = helpers.urlFormat('/passport/back/weak', { | ||
16 | + refer: refer && refer.indexOf('passport/back/weak') > -1 ? '/' : refer | ||
17 | + }); | ||
18 | + | ||
19 | + if (!req.xhr && req.user && req.user.uid && req.user.uid.isValid() && | ||
20 | + req.cookies.CSToken && req.cookies.canSkip !== 'Y' && req.path.indexOf('passport/back/weak') < 0) { | ||
21 | + return res.redirect(refer); | ||
22 | + } | ||
23 | + | ||
24 | + next(); | ||
25 | + }; | ||
26 | +}; |
-
Please register or login to post a comment