Authored by 周奇琪

Merge branch 'hotfix/loginbug'

var config = require('../config/gray');
var request = require('request');
var options=require('../staticConfig.js').staticDir;
var CSS_FILE = '/css/all.css';
var env = process.env.NODE_ENV || 'development';
//设置对于环境环境
if(env!=='development') {
CSS_FILE = options[env].path+'/all.css';
}
/**
* 登陆逻辑,跳转处理
* @param {Object} data 通过接口获取到的数据
... ... @@ -45,14 +56,14 @@ exports.post = function(data, req, res) {
res.redirect(url);
} else {
res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false});
res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false,cssfile:CSS_FILE});
}
});
return;
} else {
//否则跳转错误
res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false});
res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false,cssfile:CSS_FILE});
return;
}
}
\ No newline at end of file
... ...
... ... @@ -25,7 +25,7 @@ exports.res =
type: 'String',
maxLength: 16,
minLength: 6,
reg: /[0-9A-Za-z]{6,16}/,
reg: /^\S{6,16}/,
message: '必须是6-16位的字符'
}]
},{
... ...
... ... @@ -20,6 +20,16 @@ var NO_AUTH = '没有权限!';
var WEBSITE = 1;
var CSS_FILE = '/css/all.css';
var env = process.env.NODE_ENV || 'development';
//设置对于环境环境
if(env!=='development') {
CSS_FILE = options[env].path+'/all.css';
}
/**
* 认证中间件
* @param {Object} req 请求对象
... ... @@ -37,7 +47,7 @@ module.exports = function(req, res, next) {
var path = req.route?req.route.path:'';
if(req.session.user&&!checkPath(req.path,req)) {
res.status(403);
res.render('error/error_nolayout',{message:NO_AUTH,layout:false});
res.render('error/error_nolayout',{message:NO_AUTH,layout:false,cssfile:CSS_FILE});
return;
}
//进行白名单验证和session验证
... ... @@ -58,7 +68,7 @@ module.exports = function(req, res, next) {
} else {
req.app.logger.log('info',"CurentView:Login");
//如果是登陆界面不加载布局
res.render('pages/login',{layout:false});
res.render('pages/login',{layout:false,cssfile:CSS_FILE});
}
}
... ...
... ... @@ -7,7 +7,7 @@
<title>error</title>
<link href="/css/all.css" rel="stylesheet">
<link href="{{cssfile}}" rel="stylesheet">
</head>
<body class="pace-done">
... ...
... ... @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="/css/all.css" rel="stylesheet" type="text/css" media="screen" />
<link href="{{cssfile}}" rel="stylesheet" type="text/css" media="screen" />
</head>
<body class="signin">
<section>
... ...