Authored by mali

login secret change

... ... @@ -8,7 +8,10 @@ module.exports=function(app) {
});
app.post("/login", "common_login", function (login, req, res){
if (login.code == 200) {
console.log("common_logincommon_logincommon_logincommon_logincommon_logincommon_login" + login.pwdComplexRate);
if (login.code == 200 && login.pwdComplexRate && login.pwdComplexRate == true) { // 登录成功
if (req.session.gray) {
// 登录成功后,将phpsession保存下来
var gray_cookie = req.session.gray.replace(/[\[|\]]/g, '').split(';');
... ... @@ -21,8 +24,10 @@ module.exports=function(app) {
});
}
res.myRedirect('/');
} else {
res.myRedirect('/login?code=' + login.code);
} else if (login.code == 200 && login.pwdComplexRate && login.pwdComplexRate == false){
res.myRedirect('/account/profile/changepassword');
} else if (login.code == 200 && !login.pwdComplexRate){
res.myRedirect('/');
}
});
... ...
... ... @@ -38,12 +38,12 @@ module.exports = {
apis: {
Ilogin: {
title:'登录接口',
url: Iaccount.login,
form: '["{{user}}","{{password}}",{{website}}]',
url: Iaccount.loginEx,
// form: '["{{account}}","{{password}}",{{platform}}]', 北京erp java登录接口,只接受application/json
params: {
user: { type: String },
account: { type: String },
password: { type: String },
website: {type:Number,default: Iaccount.WEBSITE}
platform: {type:Number,default: 2}
}
},
getResourceByPid: {
... ... @@ -73,28 +73,25 @@ module.exports = {
}
},
login: function (req, callback, common) {
console.log("enter login method ........................................");
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 errcallback = function (err) {
console.log("enter login method ........................................&&&&&&&&&&&&&&&&&&&&&&&" + err);
result.code = err.errorCode;
return callback(null, result);
}
console.log("enter login method ........................................************");
console.log("begin enter common Ilogin --------------------------------------------------------------------------------------");
common.Ilogin(user, password).allRight().sessionAsync(user, password).done(function (IloginRes,allRes,sesRes) {
var userData = IloginRes.data, cookie = sesRes.caseless.dict["set-cookie"];
console.log("enter userData is ........................................" + userData);
console.log("enter common Ilogin, code: " + IloginRes.code + ", pwdComplexRate: " + IloginRes.data.pwdComplexRate);
result.code = IloginRes.code;
result.pwdComplexRate = IloginRes.data.pwdComplexRate;
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){
... ... @@ -106,7 +103,21 @@ module.exports = {
}
});
common.getResourceByPid(userData.pid, userData.role_id).done(function (getRRes) {
if (result.pwdComplexRate != undefined && !result.pwdComplexRate) { // 如果是弱密码,则需要强制修改密码,这里就不要展示任何菜单
userInfo.menu = [];
} else {
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];
... ...
... ... @@ -13,6 +13,13 @@
<%if _locals.session.user.auth %>
<div class="pull-right">
<%if _locals.session.user.passwordMsg %>
<div class="btn-group btn-group-list btn-group-notification">
<div style="margin-top: 20px; color: red;">
<%_locals.session.user.passwordMsg%>
</div>
</div>
<%/if%>
<div class="btn-group btn-group-list btn-group-notification">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="glyphicon glyphicon-user"></i>
... ... @@ -61,7 +68,8 @@
</div><!-- pull-right -->
</div>
<%/if%>
</div>
</div>
</<header>
\ No newline at end of file
... ...
... ... @@ -21,9 +21,12 @@ var options = {
/*老平台接口 配置*/
var oldSerDomain = 'http://serve.yohobuy.com';
//var javaErpDomain = 'http://qrest.yohobuy.com:9098';
var javaErpDomain = 'http://192.168.20.180';
var Iaccount = {
WEBSITE: 1,
login: oldSerDomain + '/service/account/v1/Profile/login',
loginEx: javaErpDomain + '/erp-gateway-web/account/profile/login',
getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid',
getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu',
changeShops: 'http://shops.yohobuy.com/index/ajaxshop',
... ...
... ... @@ -377,6 +377,7 @@ function __sendRequest(options, success, fail, wlen, i, args) {
}
} else {
_err_.message = "接口异常";
_err_.errorCode = response.statusCode;
console.info("Error[response state @" + options.title + "--"+options.url+"]:" + response.statusCode);
console.info(response);
console.error(_err_);
... ...
... ... @@ -4,11 +4,11 @@ if(href) {
if(index > 0) {
let code = +href.substring(index + '?code='.length);
// 登陆错误
if(code === 400) {
if(code === 500) {
alert("用户名或者密码错误,请确认!");
}
//window.location.href = "/login";
window.location.href = "/account/profile/changepassword";
window.location.href = "/login";
}
}
\ No newline at end of file
... ...