|
@@ -81,23 +81,21 @@ module.exports = { |
|
@@ -81,23 +81,21 @@ module.exports = { |
81
|
},
|
81
|
},
|
82
|
login: function (req, callback, common) {
|
82
|
login: function (req, callback, common) {
|
83
|
var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false;
|
83
|
var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false;
|
84
|
- var user = req.body.user||req.query.user;
|
|
|
85
|
- var password = req.body.password||req.query.password;
|
84
|
+ var user = req.body.user;
|
|
|
85
|
+ var password = req.body.password;
|
86
|
var errcallback = function (err) {
|
86
|
var errcallback = function (err) {
|
87
|
- return callback(null, result);
|
87
|
+ return callback(err, result);
|
88
|
};
|
88
|
};
|
89
|
var loginErrcallback = function (err) {
|
89
|
var loginErrcallback = function (err) {
|
90
|
result.needCaptcha = true;
|
90
|
result.needCaptcha = true;
|
91
|
return callback(null, result);
|
91
|
return callback(null, result);
|
92
|
};
|
92
|
};
|
|
|
93
|
+ //promise.all(Ilogin,allRight,sessionAsync).then(a,b,c);
|
93
|
|
94
|
|
94
|
common.Ilogin(user, password).done(function (IloginRes) {
|
95
|
common.Ilogin(user, password).done(function (IloginRes) {
|
95
|
- var userData = IloginRes.data,
|
|
|
96
|
- userInfo = { auth: userData, uid: userData.pid, name: userData.truename, right: {},shopList:[],brands:[]};
|
96
|
+ var userData = IloginRes.data;
|
|
|
97
|
+ userInfo = { auth: userData, uid: userData.pid, name: userData.truename, right: {},shopList:[]};
|
97
|
|
98
|
|
98
|
- if(userData.data_authority&&userData.data_authority.brand&&userData.data_authority.brand.list){
|
|
|
99
|
- userInfo.brands=userData.data_authority.brand.is_all?"0":Object.keys(userData.data_authority.brand.list);
|
|
|
100
|
- }
|
|
|
101
|
common.allRight().sessionAsync(user, password).done(function (allRes,sesRes) {
|
99
|
common.allRight().sessionAsync(user, password).done(function (allRes,sesRes) {
|
102
|
var cookie = sesRes.caseless.dict["set-cookie"];
|
100
|
var cookie = sesRes.caseless.dict["set-cookie"];
|
103
|
allRes.data.forEach(function (data) {
|
101
|
allRes.data.forEach(function (data) {
|
|
@@ -105,19 +103,40 @@ module.exports = { |
|
@@ -105,19 +103,40 @@ module.exports = { |
105
|
userInfo.right[data.path] = true;
|
103
|
userInfo.right[data.path] = true;
|
106
|
}
|
104
|
}
|
107
|
});
|
105
|
});
|
108
|
- common.getResourceByPid(userData.pid, userData.role_id).done(function (getRRes) {
|
|
|
109
|
- userInfo.menu = Utils.createrMenus(getRRes.data);
|
|
|
110
|
- req.session.user = userInfo;
|
|
|
111
|
- if (cookie && cookie.length > 0) {
|
|
|
112
|
- req.session.gray = cookie[0];
|
|
|
113
|
- result = { code: 200, message: "登录成功" ,data:req.session.user};
|
|
|
114
|
- }
|
|
|
115
|
- return callback(null, result);
|
|
|
116
|
- },errcallback);
|
106
|
+
|
|
|
107
|
+ common.getResourceByPid(userData.pid, userData.role_id)
|
|
|
108
|
+ .getShopList({ "@x-user-id": userInfo.uid }).done(function (getRRes, shopRes) {
|
|
|
109
|
+ userInfo.menu = Utils.createrMenus(getRRes.data);
|
|
|
110
|
+ if (shopRes.data) {
|
|
|
111
|
+ shopRes.data.forEach(function (data, index) {
|
|
|
112
|
+ if (!index) {
|
|
|
113
|
+ userInfo.auth.shopName = data.shopName;
|
|
|
114
|
+ userInfo.auth.shopId = data.shopsId;
|
|
|
115
|
+ }
|
|
|
116
|
+ userInfo.shopList.push({
|
|
|
117
|
+ name: data.shopName,
|
|
|
118
|
+ id: data.shopsId
|
|
|
119
|
+ });
|
|
|
120
|
+ });
|
|
|
121
|
+ req.session.user = userInfo;
|
|
|
122
|
+ if (cookie && cookie.length > 0) {
|
|
|
123
|
+ req.session.gray = cookie[0];
|
|
|
124
|
+ result = { code: 200, message: "登录成功" };
|
|
|
125
|
+ }
|
|
|
126
|
+ console.log(result);
|
|
|
127
|
+
|
|
|
128
|
+ } else {
|
|
|
129
|
+ result = { code: 400, message: "该用户没有店铺" };
|
|
|
130
|
+ }
|
|
|
131
|
+ return callback(null, result);
|
|
|
132
|
+ },errcallback);
|
117
|
|
133
|
|
118
|
}, errcallback);
|
134
|
}, errcallback);
|
|
|
135
|
+
|
119
|
}, loginErrcallback);
|
136
|
}, loginErrcallback);
|
|
|
137
|
+
|
120
|
},
|
138
|
},
|
|
|
139
|
+
|
121
|
isUsedMenuAuth:{
|
140
|
isUsedMenuAuth:{
|
122
|
title:'检查有没有权限',
|
141
|
title:'检查有没有权限',
|
123
|
url:Iaccount.isUsedMenuAuth,
|
142
|
url:Iaccount.isUsedMenuAuth,
|