Merge branch 'hotfix/loginbug'
Showing
5 changed files
with
28 additions
and
7 deletions
1 | 1 | ||
2 | var config = require('../config/gray'); | 2 | var config = require('../config/gray'); |
3 | var request = require('request'); | 3 | var request = require('request'); |
4 | +var options=require('../staticConfig.js').staticDir; | ||
5 | + | ||
6 | +var CSS_FILE = '/css/all.css'; | ||
7 | + | ||
8 | +var env = process.env.NODE_ENV || 'development'; | ||
9 | + | ||
10 | +//设置对于环境环境 | ||
11 | +if(env!=='development') { | ||
12 | + CSS_FILE = options[env].path+'/all.css'; | ||
13 | +} | ||
14 | + | ||
4 | /** | 15 | /** |
5 | * 登陆逻辑,跳转处理 | 16 | * 登陆逻辑,跳转处理 |
6 | * @param {Object} data 通过接口获取到的数据 | 17 | * @param {Object} data 通过接口获取到的数据 |
@@ -45,14 +56,14 @@ exports.post = function(data, req, res) { | @@ -45,14 +56,14 @@ exports.post = function(data, req, res) { | ||
45 | res.redirect(url); | 56 | res.redirect(url); |
46 | 57 | ||
47 | } else { | 58 | } else { |
48 | - res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false}); | 59 | + res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false,cssfile:CSS_FILE}); |
49 | } | 60 | } |
50 | }); | 61 | }); |
51 | return; | 62 | return; |
52 | } else { | 63 | } else { |
53 | 64 | ||
54 | //否则跳转错误 | 65 | //否则跳转错误 |
55 | - res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false}); | 66 | + res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false,cssfile:CSS_FILE}); |
56 | return; | 67 | return; |
57 | } | 68 | } |
58 | } | 69 | } |
@@ -25,7 +25,7 @@ exports.res = | @@ -25,7 +25,7 @@ exports.res = | ||
25 | type: 'String', | 25 | type: 'String', |
26 | maxLength: 16, | 26 | maxLength: 16, |
27 | minLength: 6, | 27 | minLength: 6, |
28 | - reg: /[0-9A-Za-z]{6,16}/, | 28 | + reg: /^\S{6,16}/, |
29 | message: '必须是6-16位的字符' | 29 | message: '必须是6-16位的字符' |
30 | }] | 30 | }] |
31 | },{ | 31 | },{ |
@@ -20,6 +20,16 @@ var NO_AUTH = '没有权限!'; | @@ -20,6 +20,16 @@ var NO_AUTH = '没有权限!'; | ||
20 | 20 | ||
21 | var WEBSITE = 1; | 21 | var WEBSITE = 1; |
22 | 22 | ||
23 | +var CSS_FILE = '/css/all.css'; | ||
24 | + | ||
25 | +var env = process.env.NODE_ENV || 'development'; | ||
26 | + | ||
27 | +//设置对于环境环境 | ||
28 | +if(env!=='development') { | ||
29 | + CSS_FILE = options[env].path+'/all.css'; | ||
30 | +} | ||
31 | + | ||
32 | + | ||
23 | /** | 33 | /** |
24 | * 认证中间件 | 34 | * 认证中间件 |
25 | * @param {Object} req 请求对象 | 35 | * @param {Object} req 请求对象 |
@@ -37,7 +47,7 @@ module.exports = function(req, res, next) { | @@ -37,7 +47,7 @@ module.exports = function(req, res, next) { | ||
37 | var path = req.route?req.route.path:''; | 47 | var path = req.route?req.route.path:''; |
38 | if(req.session.user&&!checkPath(req.path,req)) { | 48 | if(req.session.user&&!checkPath(req.path,req)) { |
39 | res.status(403); | 49 | res.status(403); |
40 | - res.render('error/error_nolayout',{message:NO_AUTH,layout:false}); | 50 | + res.render('error/error_nolayout',{message:NO_AUTH,layout:false,cssfile:CSS_FILE}); |
41 | return; | 51 | return; |
42 | } | 52 | } |
43 | //进行白名单验证和session验证 | 53 | //进行白名单验证和session验证 |
@@ -58,7 +68,7 @@ module.exports = function(req, res, next) { | @@ -58,7 +68,7 @@ module.exports = function(req, res, next) { | ||
58 | } else { | 68 | } else { |
59 | req.app.logger.log('info',"CurentView:Login"); | 69 | req.app.logger.log('info',"CurentView:Login"); |
60 | //如果是登陆界面不加载布局 | 70 | //如果是登陆界面不加载布局 |
61 | - res.render('pages/login',{layout:false}); | 71 | + res.render('pages/login',{layout:false,cssfile:CSS_FILE}); |
62 | } | 72 | } |
63 | } | 73 | } |
64 | 74 |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> |
6 | <meta name="description" content=""> | 6 | <meta name="description" content=""> |
7 | <meta name="author" content=""> | 7 | <meta name="author" content=""> |
8 | - <link href="/css/all.css" rel="stylesheet" type="text/css" media="screen" /> | 8 | + <link href="{{cssfile}}" rel="stylesheet" type="text/css" media="screen" /> |
9 | </head> | 9 | </head> |
10 | <body class="signin"> | 10 | <body class="signin"> |
11 | <section> | 11 | <section> |
-
Please register or login to post a comment