...
|
...
|
@@ -18,7 +18,7 @@ var Utils = { |
|
|
var item = {
|
|
|
title: v.menu_name,
|
|
|
}
|
|
|
if (v.parent_id === "0") {
|
|
|
if (v.parent_id === 0) {
|
|
|
item.parent = 'menu-template';
|
|
|
var itemSubs = [];
|
|
|
_.forEach(v.sub, function (val) {
|
...
|
...
|
@@ -53,22 +53,26 @@ module.exports = { |
|
|
},
|
|
|
getResourceByPid: {
|
|
|
title:'菜单接口',
|
|
|
url: Iaccount.getResourceByPid,
|
|
|
form: '[{{pid}},{{role_id}},{{website}}]',
|
|
|
// url: Iaccount.getResourceByPid,
|
|
|
url: Iaccount.getResourceByPidEx,
|
|
|
// form: '[{{pid}},{{role_id}},{{website}}]',
|
|
|
params: {
|
|
|
pid: { type: Number },
|
|
|
role_id: { type: Number },
|
|
|
website: { type: Number, default: Iaccount.WEBSITE }
|
|
|
// role_id: { type: Number },
|
|
|
// website: { type: Number, default: Iaccount.WEBSITE }
|
|
|
platform_id: { type: Number, default: Iaccount.WEBSITE }
|
|
|
}
|
|
|
},
|
|
|
allRight: {
|
|
|
title: '获取权限',
|
|
|
url: Iaccount.allRight,
|
|
|
// url: Iaccount.allRight,
|
|
|
url: Iaccount.allRightEx,
|
|
|
form: '[false]'
|
|
|
},
|
|
|
sessionAsync: {
|
|
|
title:'与老系统session同步',
|
|
|
url: Iaccount.url + '/account/login/sessions',
|
|
|
// url: Iaccount.url + '/account/login/sessions',
|
|
|
url: Iaccount.erpUrl + '/account/login/session',
|
|
|
outobj: "response",
|
|
|
form: {'account':'{{user}}','password':'{{password}}','refer': '{{refer}}'},
|
|
|
params: {
|
...
|
...
|
@@ -86,6 +90,15 @@ module.exports = { |
|
|
type:{ type: Number, default : 1 }
|
|
|
}
|
|
|
},
|
|
|
queryProfilePurviewPaths: {
|
|
|
title: '获取当前账号所有授权的权限',
|
|
|
url: Iaccount.queryProfilePurviewPaths,
|
|
|
params: {
|
|
|
pid: { type: Number },
|
|
|
role_id: { type: Number },
|
|
|
platform_id: { type: Number, default: Iaccount.WEBSITE }
|
|
|
}
|
|
|
},
|
|
|
login: function (req, callback, common) {
|
|
|
|
|
|
console.log("begin enter login function --------------------------------------------------------------------------------------" + req);
|
...
|
...
|
@@ -144,9 +157,8 @@ module.exports = { |
|
|
result.passwd_time = IloginRes.data.pwdExpirationDays;
|
|
|
|
|
|
userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]};
|
|
|
common.queryAllAuth(userData.pid).getResourceByPid(userData.pid, userData.role_id).done(function (allAuthResp, getRRes) {
|
|
|
common.queryAllAuth(userData.pid).getResourceByPid(userData.pid).queryProfilePurviewPaths(userData.pid, userData.role_id).done(function (allAuthResp, getRRes, allPPRes) {
|
|
|
console.log("enter common queryAllAuth, allAuthResp: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^1^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", allAuthResp.data.brand.list);
|
|
|
|
|
|
if(true){
|
|
|
var arrList = [];
|
|
|
console.log("enter common queryAllAuth, allAuthResp list: ******************************************************************" + (JSON.stringify(allAuthResp.data.brand.list) == "{}"));
|
...
|
...
|
@@ -163,15 +175,23 @@ module.exports = { |
|
|
|
|
|
console.log("userInfo.brands set success ; userInfo.brands is " + userInfo.brands + "(" + (typeof userInfo.brands==="string") + ")" + "*******");
|
|
|
}
|
|
|
|
|
|
allRes.data.forEach(function (data) {
|
|
|
if (data.platform_id == Iaccount.WEBSITE) {
|
|
|
userInfo.right[data.path] = true;
|
|
|
_.forEach(allRes.data, item => {
|
|
|
if (item.platform_id == Iaccount.WEBSITE ){
|
|
|
userInfo.right[item.path] = true;
|
|
|
}
|
|
|
});
|
|
|
// allRes.data.forEach(function (data) {
|
|
|
// if (data.platform_id == Iaccount.WEBSITE) {
|
|
|
// userInfo.right[data.path] = true;
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
//组织用户的菜单(切换了新接口)
|
|
|
userInfo.menu = Utils.createrMenus(getRRes.data);
|
|
|
|
|
|
//获取用户的所有权限(原为每次根据访问路径去请求接口,现改成将用户所有访问的路径都保存到session中) lzhy 2020-08-04
|
|
|
userInfo.purviewPaths = _.get(allPPRes, 'data', []);
|
|
|
|
|
|
// 如果是要过期,则需要提示用户密码要过期
|
|
|
console.log("enter getResourceByPid, passwd_time: " + result.passwd_time);
|
|
|
if (result.passwd_time != undefined && result.passwd_time > 0) {
|
...
|
...
|
@@ -230,19 +250,25 @@ module.exports = { |
|
|
'x-client-ip': req.ip,
|
|
|
'x-user-brands':typeof user.brands==="string"?user.brands: user.brands.join(',')
|
|
|
};
|
|
|
|
|
|
if (path && user.right[path]) {
|
|
|
common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){
|
|
|
result = { code: 200, message: "具有权限" };
|
|
|
if(isURes.data){
|
|
|
result={code:isURes.data.code,message:isURes.data.errmsg};
|
|
|
}
|
|
|
console.log("return result: " + JSON.stringify(isURes));
|
|
|
console.log("code 200, result: " + JSON.stringify(result));
|
|
|
return callback(null, result);
|
|
|
},function(error){
|
|
|
console.log("error: " + error);
|
|
|
return callback(error, result);
|
|
|
});
|
|
|
// 改成从缓存中读取用户所有的授权路径进行判断
|
|
|
if(_.indexOf(req.session.user.purviewPaths, path) > -1){
|
|
|
result = { code: 200, message: "具有权限" };
|
|
|
}
|
|
|
return callback(null, result);
|
|
|
// common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){
|
|
|
// result = { code: 200, message: "具有权限" };
|
|
|
// if(isURes.data){
|
|
|
// result={code:isURes.data.code,message:isURes.data.errmsg};
|
|
|
// }
|
|
|
// console.log("return result: " + JSON.stringify(isURes));
|
|
|
// console.log("code 200, result: " + JSON.stringify(result));
|
|
|
// return callback(null, result);
|
|
|
// },function(error){
|
|
|
// console.log("error: " + error);
|
|
|
// return callback(error, result);
|
|
|
// });
|
|
|
} else {
|
|
|
result = { code: 200, message: "不受权限控制" };
|
|
|
console.log(result);
|
...
|
...
|
|