Showing
6 changed files
with
50 additions
and
22 deletions
@@ -8,7 +8,10 @@ module.exports=function(app) { | @@ -8,7 +8,10 @@ module.exports=function(app) { | ||
8 | }); | 8 | }); |
9 | 9 | ||
10 | app.post("/login", "common_login", function (login, req, res){ | 10 | app.post("/login", "common_login", function (login, req, res){ |
11 | - if (login.code == 200) { | 11 | + |
12 | + console.log("common_logincommon_logincommon_logincommon_logincommon_logincommon_login" + login.pwdComplexRate); | ||
13 | + | ||
14 | + if (login.code == 200 && login.pwdComplexRate && login.pwdComplexRate == true) { // 登录成功 | ||
12 | if (req.session.gray) { | 15 | if (req.session.gray) { |
13 | // 登录成功后,将phpsession保存下来 | 16 | // 登录成功后,将phpsession保存下来 |
14 | var gray_cookie = req.session.gray.replace(/[\[|\]]/g, '').split(';'); | 17 | var gray_cookie = req.session.gray.replace(/[\[|\]]/g, '').split(';'); |
@@ -21,8 +24,10 @@ module.exports=function(app) { | @@ -21,8 +24,10 @@ module.exports=function(app) { | ||
21 | }); | 24 | }); |
22 | } | 25 | } |
23 | res.myRedirect('/'); | 26 | res.myRedirect('/'); |
24 | - } else { | ||
25 | - res.myRedirect('/login?code=' + login.code); | 27 | + } else if (login.code == 200 && login.pwdComplexRate && login.pwdComplexRate == false){ |
28 | + res.myRedirect('/account/profile/changepassword'); | ||
29 | + } else if (login.code == 200 && !login.pwdComplexRate){ | ||
30 | + res.myRedirect('/'); | ||
26 | } | 31 | } |
27 | }); | 32 | }); |
28 | 33 |
@@ -38,12 +38,12 @@ module.exports = { | @@ -38,12 +38,12 @@ module.exports = { | ||
38 | apis: { | 38 | apis: { |
39 | Ilogin: { | 39 | Ilogin: { |
40 | title:'登录接口', | 40 | title:'登录接口', |
41 | - url: Iaccount.login, | ||
42 | - form: '["{{user}}","{{password}}",{{website}}]', | 41 | + url: Iaccount.loginEx, |
42 | + // form: '["{{account}}","{{password}}",{{platform}}]', 北京erp java登录接口,只接受application/json | ||
43 | params: { | 43 | params: { |
44 | - user: { type: String }, | 44 | + account: { type: String }, |
45 | password: { type: String }, | 45 | password: { type: String }, |
46 | - website: {type:Number,default: Iaccount.WEBSITE} | 46 | + platform: {type:Number,default: 2} |
47 | } | 47 | } |
48 | }, | 48 | }, |
49 | getResourceByPid: { | 49 | getResourceByPid: { |
@@ -73,28 +73,25 @@ module.exports = { | @@ -73,28 +73,25 @@ module.exports = { | ||
73 | } | 73 | } |
74 | }, | 74 | }, |
75 | login: function (req, callback, common) { | 75 | login: function (req, callback, common) { |
76 | - | ||
77 | - console.log("enter login method ........................................"); | ||
78 | - | ||
79 | var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false; | 76 | var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false; |
80 | 77 | ||
81 | - | ||
82 | var user = req.body.user||req.query.user; | 78 | var user = req.body.user||req.query.user; |
83 | var password = req.body.password||req.query.password; | 79 | var password = req.body.password||req.query.password; |
84 | var errcallback = function (err) { | 80 | var errcallback = function (err) { |
85 | - | ||
86 | - console.log("enter login method ........................................&&&&&&&&&&&&&&&&&&&&&&&" + err); | ||
87 | - | 81 | + result.code = err.errorCode; |
88 | return callback(null, result); | 82 | return callback(null, result); |
89 | } | 83 | } |
90 | 84 | ||
91 | - console.log("enter login method ........................................************"); | ||
92 | - | 85 | + console.log("begin enter common Ilogin --------------------------------------------------------------------------------------"); |
86 | + | ||
93 | common.Ilogin(user, password).allRight().sessionAsync(user, password).done(function (IloginRes,allRes,sesRes) { | 87 | common.Ilogin(user, password).allRight().sessionAsync(user, password).done(function (IloginRes,allRes,sesRes) { |
94 | var userData = IloginRes.data, cookie = sesRes.caseless.dict["set-cookie"]; | 88 | var userData = IloginRes.data, cookie = sesRes.caseless.dict["set-cookie"]; |
95 | 89 | ||
96 | - console.log("enter userData is ........................................" + userData); | 90 | + console.log("enter common Ilogin, code: " + IloginRes.code + ", pwdComplexRate: " + IloginRes.data.pwdComplexRate); |
97 | 91 | ||
92 | + result.code = IloginRes.code; | ||
93 | + result.pwdComplexRate = IloginRes.data.pwdComplexRate; | ||
94 | + result.passwd_time = IloginRes.data.pwdExpirationDays; | ||
98 | 95 | ||
99 | userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]}; | 96 | userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]}; |
100 | if(userData.data_authority&&userData.data_authority.brand&&userData.data_authority.brand.list){ | 97 | if(userData.data_authority&&userData.data_authority.brand&&userData.data_authority.brand.list){ |
@@ -106,7 +103,21 @@ module.exports = { | @@ -106,7 +103,21 @@ module.exports = { | ||
106 | } | 103 | } |
107 | }); | 104 | }); |
108 | common.getResourceByPid(userData.pid, userData.role_id).done(function (getRRes) { | 105 | common.getResourceByPid(userData.pid, userData.role_id).done(function (getRRes) { |
109 | - userInfo.menu = Utils.createrMenus(getRRes.data); | 106 | + if (result.pwdComplexRate != undefined && !result.pwdComplexRate) { // 如果是弱密码,则需要强制修改密码,这里就不要展示任何菜单 |
107 | + userInfo.menu = []; | ||
108 | + } else { | ||
109 | + userInfo.menu = Utils.createrMenus(getRRes.data); | ||
110 | + } | ||
111 | + | ||
112 | + // 如果是要过期,则需要提示用户密码要过期 | ||
113 | + console.log("enter getResourceByPid, passwd_time: " + result.passwd_time); | ||
114 | + if (result.passwd_time != undefined && result.passwd_time > 0) { | ||
115 | + userInfo.passwordMsg = '密码' + result.passwd_time + '天后过期,请尽快修改'; | ||
116 | + } else if (result.passwd_time != undefined && result.passwd_time <= 0) { | ||
117 | + userInfo.passwordMsg = '密码已过期,请尽快修改'; | ||
118 | + } | ||
119 | + console.log("enter getResourceByPid, passwordMsg: " + userInfo.passwordMsg); | ||
120 | + | ||
110 | req.session.user = userInfo; | 121 | req.session.user = userInfo; |
111 | if (cookie && cookie.length > 0) { | 122 | if (cookie && cookie.length > 0) { |
112 | req.session.gray = cookie[0]; | 123 | req.session.gray = cookie[0]; |
@@ -13,6 +13,13 @@ | @@ -13,6 +13,13 @@ | ||
13 | <%if _locals.session.user.auth %> | 13 | <%if _locals.session.user.auth %> |
14 | 14 | ||
15 | <div class="pull-right"> | 15 | <div class="pull-right"> |
16 | + <%if _locals.session.user.passwordMsg %> | ||
17 | + <div class="btn-group btn-group-list btn-group-notification"> | ||
18 | + <div style="margin-top: 20px; color: red;"> | ||
19 | + <%_locals.session.user.passwordMsg%> | ||
20 | + </div> | ||
21 | + </div> | ||
22 | + <%/if%> | ||
16 | <div class="btn-group btn-group-list btn-group-notification"> | 23 | <div class="btn-group btn-group-list btn-group-notification"> |
17 | <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> | 24 | <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> |
18 | <i class="glyphicon glyphicon-user"></i> | 25 | <i class="glyphicon glyphicon-user"></i> |
@@ -61,7 +68,8 @@ | @@ -61,7 +68,8 @@ | ||
61 | 68 | ||
62 | </div><!-- pull-right --> | 69 | </div><!-- pull-right --> |
63 | 70 | ||
64 | - </div> | 71 | + |
65 | <%/if%> | 72 | <%/if%> |
73 | + </div> | ||
66 | </div> | 74 | </div> |
67 | </<header> | 75 | </<header> |
@@ -21,9 +21,12 @@ var options = { | @@ -21,9 +21,12 @@ var options = { | ||
21 | 21 | ||
22 | /*老平台接口 配置*/ | 22 | /*老平台接口 配置*/ |
23 | var oldSerDomain = 'http://serve.yohobuy.com'; | 23 | var oldSerDomain = 'http://serve.yohobuy.com'; |
24 | +//var javaErpDomain = 'http://qrest.yohobuy.com:9098'; | ||
25 | +var javaErpDomain = 'http://192.168.20.180'; | ||
24 | var Iaccount = { | 26 | var Iaccount = { |
25 | WEBSITE: 1, | 27 | WEBSITE: 1, |
26 | login: oldSerDomain + '/service/account/v1/Profile/login', | 28 | login: oldSerDomain + '/service/account/v1/Profile/login', |
29 | + loginEx: javaErpDomain + '/erp-gateway-web/account/profile/login', | ||
27 | getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid', | 30 | getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid', |
28 | getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu', | 31 | getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu', |
29 | changeShops: 'http://shops.yohobuy.com/index/ajaxshop', | 32 | changeShops: 'http://shops.yohobuy.com/index/ajaxshop', |
@@ -377,6 +377,7 @@ function __sendRequest(options, success, fail, wlen, i, args) { | @@ -377,6 +377,7 @@ function __sendRequest(options, success, fail, wlen, i, args) { | ||
377 | } | 377 | } |
378 | } else { | 378 | } else { |
379 | _err_.message = "接口异常"; | 379 | _err_.message = "接口异常"; |
380 | + _err_.errorCode = response.statusCode; | ||
380 | console.info("Error[response state @" + options.title + "--"+options.url+"]:" + response.statusCode); | 381 | console.info("Error[response state @" + options.title + "--"+options.url+"]:" + response.statusCode); |
381 | console.info(response); | 382 | console.info(response); |
382 | console.error(_err_); | 383 | console.error(_err_); |
@@ -4,11 +4,11 @@ if(href) { | @@ -4,11 +4,11 @@ if(href) { | ||
4 | if(index > 0) { | 4 | if(index > 0) { |
5 | let code = +href.substring(index + '?code='.length); | 5 | let code = +href.substring(index + '?code='.length); |
6 | // 登陆错误 | 6 | // 登陆错误 |
7 | - if(code === 400) { | 7 | + if(code === 500) { |
8 | alert("用户名或者密码错误,请确认!"); | 8 | alert("用户名或者密码错误,请确认!"); |
9 | } | 9 | } |
10 | 10 | ||
11 | - //window.location.href = "/login"; | ||
12 | - window.location.href = "/account/profile/changepassword"; | 11 | + window.location.href = "/login"; |
13 | } | 12 | } |
13 | + | ||
14 | } | 14 | } |
-
Please register or login to post a comment