Authored by 姜敏

Merge branch 'release/1.6' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into release/1.6

@@ -42,24 +42,24 @@ exports.post = function(data, req, res) { @@ -42,24 +42,24 @@ exports.post = function(data, req, res) {
42 } 42 }
43 } 43 }
44 req.app.logger.log('verbose','gray login options:',options); 44 req.app.logger.log('verbose','gray login options:',options);
45 - // request(options,function(err,ress,body){  
46 - // if(!err) {  
47 - // //cookie透传到老系统  
48 - // var cookie = ress.caseless.get('set-cookie');  
49 - // req.app.logger.log('verbose','login old server response http headers:',ress.caseless);  
50 - // req.app.logger.log('verbose','login gray cookie:',cookie);  
51 - // //如果没有设置到session  
52 - // if(cookie && cookie.length>0) {  
53 - // req.session.gray = cookie[0];  
54 - // }  
55 - // //跳转  
56 - // res.redirect(url); 45 + request(options,function(err,ress,body){
  46 + if(!err) {
  47 + //cookie透传到老系统
  48 + var cookie = ress.caseless.get('set-cookie');
  49 + req.app.logger.log('verbose','login old server response http headers:',ress.caseless);
  50 + req.app.logger.log('verbose','login gray cookie:',cookie);
  51 + //如果没有设置到session
  52 + if(cookie && cookie.length>0) {
  53 + req.session.gray = cookie[0];
  54 + }
  55 + //跳转
  56 + res.redirect(url);
57 57
58 - // } else {  
59 - // res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false,cssfile:CSS_FILE});  
60 - // }  
61 - // });  
62 - res.redirect(url); 58 + } else {
  59 + res.render('error/error_nolayout',{message:'用户名或者密码错误!',layout:false,cssfile:CSS_FILE});
  60 + }
  61 + });
  62 + // res.redirect(url);
63 return; 63 return;
64 } else { 64 } else {
65 65
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 * @type {Object} 3 * @type {Object}
4 */ 4 */
5 module.exports = { 5 module.exports = {
6 - url:'http://admin.yohobuy.com',//'http://admin.portal.yohobuy.com', 6 + url:'http://admin.portal.yohobuy.com',
7 sessionKeep:'/account/profile/display', 7 sessionKeep:'/account/profile/display',
8 timeout:30000 8 timeout:30000
9 }; 9 };
@@ -79,28 +79,28 @@ module.exports = function(req, res, next) { @@ -79,28 +79,28 @@ module.exports = function(req, res, next) {
79 } 79 }
80 //访问路由路径 80 //访问路由路径
81 var path = req.route?req.route.path:filterOriginalUrl(req.originalUrl); 81 var path = req.route?req.route.path:filterOriginalUrl(req.originalUrl);
82 - // if(req.session.user) {  
83 - // if(guestAccessList[method+":"+path]){  
84 - // nextRedirect(method,path);  
85 - // return;  
86 - // }  
87 - // /*判断权限*/  
88 - // if(path&&req.session.user.allRight[path]){  
89 - // author.validateAuthor(req.session.user.auth.pid,req.session.user.auth.role_id,path,function(data){  
90 - // if(data.code!=200){  
91 - // res.status(403);  
92 - // res.render('error/error_nolayout',{message:NO_AUTH,layout:false,cssfile:CSS_FILE});  
93 - // return;  
94 - // }  
95 - // nextRedirect(method,path);  
96 - // });  
97 - // }else{  
98 - // nextRedirect(method,path);  
99 - // }  
100 - // }else{  
101 - // nextRedirect(method,path);  
102 - // }  
103 - nextRedirect(method,path); 82 + if(req.session.user) {
  83 + if(guestAccessList[method+":"+path]){
  84 + nextRedirect(method,path);
  85 + return;
  86 + }
  87 + /*判断权限*/
  88 + if(path&&req.session.user.allRight[path]){
  89 + author.validateAuthor(req.session.user.auth.pid,req.session.user.auth.role_id,path,function(data){
  90 + if(data.code!=200){
  91 + res.status(403);
  92 + res.render('error/error_nolayout',{message:NO_AUTH,layout:false,cssfile:CSS_FILE});
  93 + return;
  94 + }
  95 + nextRedirect(method,path);
  96 + });
  97 + }else{
  98 + nextRedirect(method,path);
  99 + }
  100 + }else{
  101 + nextRedirect(method,path);
  102 + }
  103 + // nextRedirect(method,path);
104 } 104 }
105 105
106 /** 106 /**
@@ -81,7 +81,7 @@ module.exports = function(proxyRoute) { @@ -81,7 +81,7 @@ module.exports = function(proxyRoute) {
81 }); 81 });
82 } else { 82 } else {
83 request(options).pipe(ress);//如果是静态资源,直接管道传递结果 83 request(options).pipe(ress);//如果是静态资源,直接管道传递结果
84 - } 84 + }
85 } else { 85 } else {
86 86
87 //当不是老系统的URL,需要访问老系统保持session 87 //当不是老系统的URL,需要访问老系统保持session