IDEMPIERE-2266 ZK7 - MSession.load: NO Data found for AD_Session_ID

This commit is contained in:
Carlos Ruiz 2016-03-22 22:47:34 +01:00
parent 18e494fd12
commit b716da12a9
1 changed files with 33 additions and 29 deletions

View File

@ -150,36 +150,40 @@ public class LoginPanel extends Window implements EventListener<Event>
try try
{ {
int AD_Session_ID = Integer.parseInt(data[0]); int AD_Session_ID = Integer.parseInt(data[0]);
MSession session = new MSession(Env.getCtx(), AD_Session_ID, null); int cnt = DB.getSQLValueEx(null, "SELECT COUNT(*) FROM AD_Session WHERE AD_Session_ID=?", AD_Session_ID);
if (session.get_ID() == AD_Session_ID) if (cnt == 1)
{ {
int AD_User_ID = session.getCreatedBy(); MSession session = new MSession(Env.getCtx(), AD_Session_ID, null);
MUser user = MUser.get(Env.getCtx(), AD_User_ID); if (session.get_ID() == AD_Session_ID)
if (user != null && user.get_ID() == AD_User_ID)
{ {
String token = data[1]; int AD_User_ID = session.getCreatedBy();
if (BrowserToken.validateToken(session, user, token)) MUser user = MUser.get(Env.getCtx(), AD_User_ID);
{ if (user != null && user.get_ID() == AD_User_ID)
if (MSystem.isZKRememberUserAllowed()) { {
if (email_login) { String token = data[1];
txtUserId.setValue(user.getEMail()); if (BrowserToken.validateToken(session, user, token))
} else { {
if (user.getLDAPUser() != null && user.getLDAPUser().length() > 0) { if (MSystem.isZKRememberUserAllowed()) {
txtUserId.setValue(user.getLDAPUser()); if (email_login) {
} else { txtUserId.setValue(user.getEMail());
txtUserId.setValue(user.getName()); } else {
} if (user.getLDAPUser() != null && user.getLDAPUser().length() > 0) {
} txtUserId.setValue(user.getLDAPUser());
onUserIdChange(AD_User_ID); } else {
chkRememberMe.setChecked(true); txtUserId.setValue(user.getName());
} }
if (MSystem.isZKRememberPasswordAllowed()) { }
txtPassword.setValue(token); onUserIdChange(AD_User_ID);
txtPassword.setAttribute("user.token.hash", token); chkRememberMe.setChecked(true);
txtPassword.setAttribute("user.token.sid", AD_Session_ID); }
} if (MSystem.isZKRememberPasswordAllowed()) {
chkSelectRole.setChecked(false); txtPassword.setValue(token);
} txtPassword.setAttribute("user.token.hash", token);
txtPassword.setAttribute("user.token.sid", AD_Session_ID);
}
chkSelectRole.setChecked(false);
}
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -567,7 +571,7 @@ public class LoginPanel extends Window implements EventListener<Event>
// IDEMPIERE-617 // IDEMPIERE-617
String x_Forward_IP = Executions.getCurrent().getHeader("X-Forwarded-For"); String x_Forward_IP = Executions.getCurrent().getHeader("X-Forwarded-For");
if (x_Forward_IP == null) { if (x_Forward_IP == null) {
x_Forward_IP = currSess.getRemoteAddr(); x_Forward_IP = Executions.getCurrent().getRemoteAddr();
} }
logAuthFailure.log(x_Forward_IP, "/webui", userId, loginErrMsg); logAuthFailure.log(x_Forward_IP, "/webui", userId, loginErrMsg);