Authored by 周奇琪

Merge branch 'hotfix/loginbug' into develop

Conflicts:
	server/views/pages/login.html
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 }
@@ -26,7 +26,7 @@ exports.res = @@ -26,7 +26,7 @@ exports.res =
26 type: 'String', 26 type: 'String',
27 maxLength: 16, 27 maxLength: 16,
28 minLength: 6, 28 minLength: 6,
29 - reg: /[0-9A-Za-z]{6,16}/, 29 + reg: /^\S{6,16}/,
30 message: '必须是6-16位的字符' 30 message: '必须是6-16位的字符'
31 }] 31 }]
32 },{ 32 },{
@@ -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
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 <title>error</title> 8 <title>error</title>
9 9
10 - <link href="/css/all.css" rel="stylesheet"> 10 + <link href="{{cssfile}}" rel="stylesheet">
11 </head> 11 </head>
12 12
13 <body class="pace-done"> 13 <body class="pace-done">