...
|
...
|
@@ -72,6 +72,15 @@ module.exports = { |
|
|
refer:{type:String,default:'%2Faccount%2Fprofile%2Fdisplay'}
|
|
|
}
|
|
|
},
|
|
|
queryAllAuth: {
|
|
|
title:'获取当前账号的品牌和店铺权限',
|
|
|
url: Iaccount.queryAllAuth,
|
|
|
//form: {'pid':'{{user}}'},
|
|
|
params: {
|
|
|
pid: { type: Number },
|
|
|
type:{ type: Number, default : 1 }
|
|
|
}
|
|
|
},
|
|
|
login: function (req, callback, common) {
|
|
|
var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false;
|
|
|
|
...
|
...
|
@@ -94,39 +103,53 @@ module.exports = { |
|
|
result.passwd_time = IloginRes.data.pwdExpirationDays;
|
|
|
|
|
|
userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]};
|
|
|
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);
|
|
|
}
|
|
|
allRes.data.forEach(function (data) {
|
|
|
if (data.platform_id == Iaccount.WEBSITE) {
|
|
|
userInfo.right[data.path] = true;
|
|
|
}
|
|
|
});
|
|
|
common.getResourceByPid(userData.pid, userData.role_id).done(function (getRRes) {
|
|
|
/* if (result.pwdComplexRate != undefined && !result.pwdComplexRate) { // 如果是弱密码,则需要强制修改密码,这里就不要展示任何菜单
|
|
|
userInfo.menu = [];
|
|
|
} else {
|
|
|
common.queryAllAuth(userData.pid).getResourceByPid(userData.pid, userData.role_id).done(function (allAuthResp, getRRes) {
|
|
|
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) == "{}"));
|
|
|
if (JSON.stringify(allAuthResp.data.brand.list) == "{}") {
|
|
|
userInfo.brands=allAuthResp.data.brand.is_all?"0": Object.keys(arrList);
|
|
|
console.log("enter common queryAllAuth arrList (((((((((((((((((((((((((((((((((((((");
|
|
|
} else {
|
|
|
var test1 = {"hh" : {"2": "2", "144" : "144", "349":"349","1572":"1572"}}; // 2,144,349,1572
|
|
|
userInfo.brands=allAuthResp.data.brand.is_all?"0": Object.keys(allAuthResp.data.brand.list);
|
|
|
console.log("enter common queryAllAuth list ((((((((((((((((((((((((((((((((((((()))))))" + Object.keys(allAuthResp.data.brand.list) + "************" + Object.keys(test1.hh));
|
|
|
// userInfo.brands=userData.data_authority.brand.is_all?"0":Object.keys(userData.data_authority.brand.list);
|
|
|
//userInfo.brands = [2,144,349,1572];
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
console.log("userInfo.brands set success ; userInfo.brands is " + userInfo.brands + "(" + (typeof userInfo.brands==="string") + ")" + "*******");
|
|
|
|
|
|
userInfo.menu = Utils.createrMenus(getRRes.data);
|
|
|
allRes.data.forEach(function (data) {
|
|
|
if (data.platform_id == Iaccount.WEBSITE) {
|
|
|
userInfo.right[data.path] = true;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 如果是要过期,则需要提示用户密码要过期
|
|
|
console.log("enter getResourceByPid, passwd_time: " + result.passwd_time);
|
|
|
if (result.passwd_time != undefined && result.passwd_time > 0) {
|
|
|
userInfo.passwordMsg = '密码' + result.passwd_time + '天后过期,请尽快修改';
|
|
|
} else if (result.passwd_time != undefined && result.passwd_time <= 0) {
|
|
|
userInfo.passwordMsg = '密码已过期,请尽快修改';
|
|
|
}
|
|
|
console.log("enter getResourceByPid, passwordMsg: " + userInfo.passwordMsg);
|
|
|
|
|
|
req.session.user = userInfo;
|
|
|
if (cookie && cookie.length > 0) {
|
|
|
req.session.gray = cookie[0];
|
|
|
result = { code: 200, message: "登录成功" ,data:req.session.user,pwdComplexRate :IloginRes.data.pwdComplexRate};
|
|
|
userInfo.menu = Utils.createrMenus(getRRes.data);
|
|
|
|
|
|
// 如果是要过期,则需要提示用户密码要过期
|
|
|
console.log("enter getResourceByPid, passwd_time: " + result.passwd_time);
|
|
|
if (result.passwd_time != undefined && result.passwd_time > 0) {
|
|
|
userInfo.passwordMsg = '密码' + result.passwd_time + '天后过期,请尽快修改';
|
|
|
} else if (result.passwd_time != undefined && result.passwd_time <= 0) {
|
|
|
userInfo.passwordMsg = '密码已过期,请尽快修改';
|
|
|
}
|
|
|
console.log("enter getResourceByPid, passwordMsg: " + userInfo.passwordMsg);
|
|
|
|
|
|
req.session.user = userInfo;
|
|
|
if (cookie && cookie.length > 0) {
|
|
|
req.session.gray = cookie[0];
|
|
|
result = { code: 200, message: "登录成功" ,data:req.session.user,pwdComplexRate :IloginRes.data.pwdComplexRate};
|
|
|
}
|
|
|
return callback(null, result);
|
|
|
}
|
|
|
return callback(null, result);
|
|
|
},errcallback);
|
|
|
}, errcallback);
|
|
|
|
|
|
|
|
|
|
|
|
}, errcallback);
|
|
|
},
|
|
|
isUsedMenuAuth:{
|
...
|
...
|
@@ -145,7 +168,7 @@ module.exports = { |
|
|
if (req.session && req.session.user) {
|
|
|
var user = req.session.user;
|
|
|
var path = req.route?req.route.path[0]:req.originalUrl.replace(/\?.+/, '');
|
|
|
console.log("enter gray filter, user: " + user + ", path: " + path);
|
|
|
console.log("enter gray filter, user: " + user + ", path: " + path + ", brands" + user.brands);
|
|
|
req._yoheaders = {
|
|
|
'x-user-id': user.auth.pid,
|
|
|
'x-user-name': user.auth.account,//防止header中包含中文
|
...
|
...
|
|