IDEMPIERE-375 Implement Forgot my Password - improve the user-friendliness

This commit is contained in:
Elaine Tan 2012-10-10 17:35:36 +08:00
parent 0bca8c738b
commit 8000086ad4
5 changed files with 109 additions and 8 deletions

View File

@ -0,0 +1,32 @@
-- Oct 10, 2012 4:12:00 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Forgot My Password',200074,'D','edbc8af4-43a1-4966-8ee5-c609cf01a90c','ForgotMyPassword','Y',TO_DATE('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS'))
;
-- Oct 10, 2012 4:12:00 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200074 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Oct 10, 2012 4:29:44 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Passwords for all tenants using ({0}) as email have been reset',' ',200075,'D','51b49e9a-4c26-486a-ac83-e506ce282ab7','PasswordsForAllTenantsReset','Y',TO_DATE('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS'))
;
-- Oct 10, 2012 4:29:44 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200075 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Oct 10, 2012 4:31:02 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','The new password is now valid for all tenants',' ',200076,'D','be10802e-1a38-45cf-afd9-5bbe1776fead','NewPasswordValidForAllTenants','Y',TO_DATE('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_DATE('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS'))
;
-- Oct 10, 2012 4:31:02 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200076 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('931_IDEMPIERE-375.sql') FROM dual
;

View File

@ -0,0 +1,32 @@
-- Oct 10, 2012 4:12:00 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Forgot My Password',200074,'D','edbc8af4-43a1-4966-8ee5-c609cf01a90c','ForgotMyPassword','Y',TO_TIMESTAMP('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-10 16:11:57','YYYY-MM-DD HH24:MI:SS'))
;
-- Oct 10, 2012 4:12:00 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200074 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Oct 10, 2012 4:29:44 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','Passwords for all tenants using ({0}) as email have been reset',' ',200075,'D','51b49e9a-4c26-486a-ac83-e506ce282ab7','PasswordsForAllTenantsReset','Y',TO_TIMESTAMP('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-10 16:29:43','YYYY-MM-DD HH24:MI:SS'))
;
-- Oct 10, 2012 4:29:44 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200075 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
-- Oct 10, 2012 4:31:02 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created) VALUES ('I','The new password is now valid for all tenants',' ',200076,'D','be10802e-1a38-45cf-afd9-5bbe1776fead','NewPasswordValidForAllTenants','Y',TO_TIMESTAMP('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS'),100,100,0,0,TO_TIMESTAMP('2012-10-10 16:31:01','YYYY-MM-DD HH24:MI:SS'))
;
-- Oct 10, 2012 4:31:02 PM SGT
-- IDEMPIERE-375 Implement Forgot my Password
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200076 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('931_IDEMPIERE-375.sql') FROM dual
;

View File

@ -18,11 +18,14 @@ package org.adempiere.webui.panel;
import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.Callback;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Combobox;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Messagebox;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
@ -331,7 +334,7 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
user.saveEx(trx.getTrxName());
}
trx.commit();
trx.commit();
}
catch (AdempiereException e)
{
@ -345,6 +348,13 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
trx.close();
}
wndLogin.loginOk(m_userName, m_show, m_clientKNPairs);
String msg = Msg.getMsg(m_ctx, "NewPasswordValidForAllTenants");
Messagebox.showDialog(msg, AEnv.getDialogHeader(Env.getCtx(), 0), Messagebox.OK, Messagebox.INFORMATION, new Callback<Integer>() {
@Override
public void onCallback(Integer result) {
wndLogin.loginOk(m_userName, m_show, m_clientKNPairs);
}
});
}
}

View File

@ -348,7 +348,7 @@ public class LoginPanel extends Window implements EventListener<Event>
chkSelectRole = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "SelectRole"));
btnResetPassword = new ToolBarButton(Msg.getMsg(Language.getBaseAD_Language(), "ResetPassword"));
btnResetPassword = new ToolBarButton(Msg.getMsg(Language.getBaseAD_Language(), "ForgotMyPassword"));
// Make the default language the language of client System
String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
@ -455,7 +455,7 @@ public class LoginPanel extends Window implements EventListener<Event>
lblLanguage.setValue(Msg.getMsg(language, "Language"));
chkRememberMe.setLabel(Msg.getMsg(language, "RememberMe"));
chkSelectRole.setLabel(Msg.getMsg(language, "SelectRole"));
btnResetPassword.setLabel(Msg.getMsg(language, "ResetPassword"));
btnResetPassword.setLabel(Msg.getMsg(language, "ForgotMyPassword"));
}
private Language findLanguage(String langName) {

View File

@ -21,10 +21,13 @@ import java.util.List;
import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.Callback;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Messagebox;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
@ -112,7 +115,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
{
Div div = new Div();
div.setSclass(ITheme.LOGIN_BOX_HEADER_CLASS);
Label label = new Label(Msg.getMsg(m_ctx, "ResetPassword"));
Label label = new Label(Msg.getMsg(m_ctx, "ForgotMyPassword"));
label.setSclass(ITheme.LOGIN_BOX_HEADER_TXT_CLASS);
div.appendChild(label);
this.appendChild(div);
@ -229,15 +232,18 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtUserId.setCols(25);
txtUserId.setMaxlength(40);
txtUserId.setWidth("220px");
txtUserId.setReadonly(false);
if (! m_noSecurityQuestion)
{
lblSecurityQuestion = new Label();
lblSecurityQuestion.setId("lblSecurityQuestion");
lblSecurityQuestion.setValue(Msg.getMsg(m_ctx, "SecurityQuestion"));
lblSecurityQuestion.setVisible(false);
lblAnswer = new Label();
lblAnswer.setId("lblAnswer");
lblAnswer.setValue(Msg.getMsg(m_ctx, "Answer"));
lblAnswer.setVisible(false);
txtSecurityQuestion = new Textbox();
txtSecurityQuestion.setId("txtSecurityQuestion");
@ -245,6 +251,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtSecurityQuestion.setCols(25);
txtSecurityQuestion.setWidth("220px");
txtSecurityQuestion.setReadonly(true);
txtSecurityQuestion.setVisible(false);
txtAnswer = new Textbox();
txtAnswer.setId("txtAnswer");
@ -253,6 +260,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtAnswer.setCols(25);
txtAnswer.setWidth("220px");
txtAnswer.setReadonly(true);
txtAnswer.setVisible(false);
}
}
@ -283,10 +291,22 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
sql.append("ORDER BY AD_Client_ID DESC");
String securityQuestion = DB.getSQLValueString(null, sql.toString(), userid, email);
if (securityQuestion == null)
{
m_noSecurityQuestion = true;
validateResetPassword();
return;
}
txtSecurityQuestion.setValue(securityQuestion);
txtUserId.setReadonly(true);
txtEmail.setReadonly(true);
txtAnswer.setReadonly(false);
lblSecurityQuestion.setVisible(true);
lblAnswer.setVisible(true);
txtSecurityQuestion.setVisible(true);
txtAnswer.setVisible(true);
}
public void onEvent(Event event)
@ -457,9 +477,16 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
throw new AdempiereException(Msg.getMsg(m_ctx, "RequestActionEMailError") + ": " + errorMsg);
else
{
SessionManager.logoutSession();
wndLogin.loginCancelled();
// FDialog.info(0, this, Msg.getMsg(m_ctx, "RequestActionEMailOK"));
// Passwords for all tenants using ({0}) as email have been reset
String msg = Msg.getMsg(m_ctx, "PasswordsForAllTenantsReset", new Object[] {email});
Messagebox.showDialog(msg, AEnv.getDialogHeader(Env.getCtx(), 0), Messagebox.OK, Messagebox.INFORMATION, new Callback<Integer>() {
@Override
public void onCallback(Integer result) {
SessionManager.logoutSession();
wndLogin.loginCancelled();
}
});
}
}