IDEMPIERE-375 Implement Forgot my Password / Implement back the list of security questions and save the question instead the key

This commit is contained in:
Carlos Ruiz 2012-09-13 15:23:28 -05:00
parent 92f9a9f47c
commit 35d23b0cdf
2 changed files with 30 additions and 11 deletions

View File

@ -20,6 +20,7 @@ import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Combobox;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Textbox;
@ -75,10 +76,10 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
private Label lblRetypeNewPassword;
private Label lblSecurityQuestion;
private Label lblAnswer;
private Combobox lstSecurityQuestion;
private Textbox txtOldPassword;
private Textbox txtNewPassword;
private Textbox txtRetypeNewPassword;
private Textbox txtSecurityQuestion;
private Textbox txtAnswer;
public ChangePasswordPanel(Properties ctx, LoginWindow loginWindow, String userName, String userPassword, boolean show, KeyNamePair[] clientsKNPairs)
@ -168,7 +169,7 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
td = new Td();
td.setSclass(ITheme.LOGIN_FIELD_CLASS);
tr.appendChild(td);
td.appendChild(txtSecurityQuestion);
td.appendChild(lstSecurityQuestion);
tr = new Tr();
tr.setId("rowAnswer");
@ -215,7 +216,18 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
lblAnswer = new Label();
lblAnswer.setId("lblAnswer");
lblAnswer.setValue(Msg.getMsg(m_ctx, "Answer"));
lstSecurityQuestion = new Combobox();
lstSecurityQuestion.setAutocomplete(true);
lstSecurityQuestion.setAutodrop(true);
lstSecurityQuestion.setId("lstSecurityQuestion");
lstSecurityQuestion.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstSecurityQuestion.getId());
lstSecurityQuestion.setWidth("220px");
lstSecurityQuestion.getItems().clear();
for (int i = 1; i <= ResetPasswordPanel.NO_OF_SECURITY_QUESTION; i++)
lstSecurityQuestion.appendItem(Msg.getMsg(m_ctx, ResetPasswordPanel.SECURITY_QUESTION_PREFIX + i), ResetPasswordPanel.SECURITY_QUESTION_PREFIX + i);
txtOldPassword = new Textbox();
txtOldPassword.setId("txtOldPassword");
txtOldPassword.setType("password");
@ -237,12 +249,6 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
txtRetypeNewPassword.setCols(25);
txtRetypeNewPassword.setWidth("220px");
txtSecurityQuestion = new Textbox();
txtSecurityQuestion.setId("txtSecurityQuestion");
txtSecurityQuestion.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtSecurityQuestion.getId());
txtSecurityQuestion.setCols(25);
txtSecurityQuestion.setWidth("220px");
txtAnswer = new Textbox();
txtAnswer.setId("txtAnswer");
// txtAnswer.setType("password");
@ -268,8 +274,12 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
{
String oldPassword = txtOldPassword.getValue();
String newPassword = txtNewPassword.getValue();
String retypeNewPassword = txtRetypeNewPassword.getValue();
String securityQuestion = txtSecurityQuestion.getValue();
String retypeNewPassword = txtRetypeNewPassword.getValue();
String securityQuestion = null;
if (lstSecurityQuestion.getSelectedItem() != null)
securityQuestion = (String) lstSecurityQuestion.getSelectedItem().getLabel();
String answer = txtAnswer.getValue();
if (Util.isEmpty(oldPassword))

View File

@ -66,7 +66,9 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
private static CLogger logger = CLogger.getCLogger(ResetPasswordPanel.class);
private static final int MAX_RESET_PASSWORD_TRIES = 3;
private static final int MAX_RESET_PASSWORD_TRIES = 3;
protected static final int NO_OF_SECURITY_QUESTION = 5;
protected static final String SECURITY_QUESTION_PREFIX = "SecurityQuestion_";
private static final String RESET_PASSWORD_MAIL_TEXT_NAME = "Reset Password";
private LoginWindow wndLogin;
@ -488,6 +490,13 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
mailText.setUser(to);
String message = mailText.getMailText(true);
message = Env.parseVariable(message, to, to.get_TrxName(), true);
/* ?? DEBUG ?? */
System.out.println(message);
if (true)
return true;
EMail email = client.createEMail(to.getEMail(), mailText.getMailHeader(), message, mailText.isHtml());
if (mailText.isHtml())
email.setMessageHTML(mailText.getMailHeader(), message);