...
|
...
|
@@ -81,23 +81,21 @@ module.exports = { |
|
|
},
|
|
|
login: function (req, callback, common) {
|
|
|
var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false;
|
|
|
var user = req.body.user||req.query.user;
|
|
|
var password = req.body.password||req.query.password;
|
|
|
var user = req.body.user;
|
|
|
var password = req.body.password;
|
|
|
var errcallback = function (err) {
|
|
|
return callback(null, result);
|
|
|
return callback(err, result);
|
|
|
};
|
|
|
var loginErrcallback = function (err) {
|
|
|
result.needCaptcha = true;
|
|
|
return callback(null, result);
|
|
|
};
|
|
|
//promise.all(Ilogin,allRight,sessionAsync).then(a,b,c);
|
|
|
|
|
|
common.Ilogin(user, password).done(function (IloginRes) {
|
|
|
var userData = IloginRes.data,
|
|
|
userInfo = { auth: userData, uid: userData.pid, name: userData.truename, right: {},shopList:[],brands:[]};
|
|
|
var userData = IloginRes.data;
|
|
|
userInfo = { auth: userData, uid: userData.pid, name: userData.truename, right: {},shopList:[]};
|
|
|
|
|
|
if(userData.data_authority&&userData.data_authority.brand&&userData.data_authority.brand.list){
|
|
|
userInfo.brands=userData.data_authority.brand.is_all?"0":Object.keys(userData.data_authority.brand.list);
|
|
|
}
|
|
|
common.allRight().sessionAsync(user, password).done(function (allRes,sesRes) {
|
|
|
var cookie = sesRes.caseless.dict["set-cookie"];
|
|
|
allRes.data.forEach(function (data) {
|
...
|
...
|
@@ -105,19 +103,40 @@ module.exports = { |
|
|
userInfo.right[data.path] = true;
|
|
|
}
|
|
|
});
|
|
|
common.getResourceByPid(userData.pid, userData.role_id).done(function (getRRes) {
|
|
|
|
|
|
common.getResourceByPid(userData.pid, userData.role_id)
|
|
|
.getShopList({ "@x-user-id": userInfo.uid }).done(function (getRRes, shopRes) {
|
|
|
userInfo.menu = Utils.createrMenus(getRRes.data);
|
|
|
if (shopRes.data) {
|
|
|
shopRes.data.forEach(function (data, index) {
|
|
|
if (!index) {
|
|
|
userInfo.auth.shopName = data.shopName;
|
|
|
userInfo.auth.shopId = data.shopsId;
|
|
|
}
|
|
|
userInfo.shopList.push({
|
|
|
name: data.shopName,
|
|
|
id: data.shopsId
|
|
|
});
|
|
|
});
|
|
|
req.session.user = userInfo;
|
|
|
if (cookie && cookie.length > 0) {
|
|
|
req.session.gray = cookie[0];
|
|
|
result = { code: 200, message: "登录成功" ,data:req.session.user};
|
|
|
result = { code: 200, message: "登录成功" };
|
|
|
}
|
|
|
console.log(result);
|
|
|
|
|
|
} else {
|
|
|
result = { code: 400, message: "该用户没有店铺" };
|
|
|
}
|
|
|
return callback(null, result);
|
|
|
},errcallback);
|
|
|
|
|
|
}, errcallback);
|
|
|
|
|
|
}, loginErrcallback);
|
|
|
|
|
|
},
|
|
|
|
|
|
isUsedMenuAuth:{
|
|
|
title:'检查有没有权限',
|
|
|
url:Iaccount.isUsedMenuAuth,
|
...
|
...
|
|