Skip to content

Commit

Permalink
LPS-107063 Make the user security answer invisible based on the property
Browse files Browse the repository at this point in the history
  • Loading branch information
Marta Medio authored and brianchandotcom committed Oct 9, 2020
1 parent a8bff07 commit 5e2da78
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ protected void updatePassword(
_userLocalService.updatePasswordReset(user.getUserId(), passwordReset);

if (Validator.isNotNull(reminderQueryQuestion) &&
Validator.isNotNull(reminderQueryAnswer)) {
Validator.isNotNull(reminderQueryAnswer) &&
!reminderQueryAnswer.equals(Portal.TEMP_OBFUSCATION_VALUE)) {

_userLocalService.updateReminderQuery(
user.getUserId(), reminderQueryQuestion, reminderQueryAnswer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ renderResponse.setTitle(LanguageUtil.get(request, "forgot-password"));
<liferay-ui:message arguments="<%= HtmlUtil.escape(login) %>" key="an-email-will-be-sent-to-x-if-you-can-correctly-answer-the-following-question" translateArguments="<%= false %>" />
</div>

<aui:input autoFocus="<%= true %>" label="<%= HtmlUtil.escape(LanguageUtil.get(request, user2.getReminderQueryQuestion())) %>" name="answer" type="text" />
<aui:input autoFocus="<%= true %>" label="<%= HtmlUtil.escape(LanguageUtil.get(request, user2.getReminderQueryQuestion())) %>" name="answer" type="password" />
</c:if>

<c:choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ protected void doProcessAction(
user.getUserId(), passwordReset);

if (Validator.isNotNull(reminderQueryQuestion) &&
Validator.isNotNull(reminderQueryAnswer)) {
Validator.isNotNull(reminderQueryAnswer) &&
!reminderQueryAnswer.equals(Portal.TEMP_OBFUSCATION_VALUE)) {

_userLocalService.updateReminderQuery(
user.getUserId(), reminderQueryQuestion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ page import="com.liferay.portal.kernel.util.KeyValuePair" %><%@
page import="com.liferay.portal.kernel.util.ListUtil" %><%@
page import="com.liferay.portal.kernel.util.LocalizationUtil" %><%@
page import="com.liferay.portal.kernel.util.ParamUtil" %><%@
page import="com.liferay.portal.kernel.util.Portal" %><%@
page import="com.liferay.portal.kernel.util.PortalUtil" %><%@
page import="com.liferay.portal.kernel.util.PortletKeys" %><%@
page import="com.liferay.portal.kernel.util.PropsKeys" %><%@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ else {
</div>
</c:if>

<aui:input autocomplete='<%= PropsValues.COMPANY_SECURITY_PASSWORD_REMINDER_QUERY_FORM_AUTOCOMPLETE ? "on" : "off" %>' label="answer" maxlength="<%= ModelHintsConstants.TEXT_MAX_LENGTH %>" name="reminderQueryAnswer" size="50" value="<%= selUser.getReminderQueryAnswer() %>" />
<%
String answer = selUser.getReminderQueryAnswer();
if (!PropsValues.USERS_REMINDER_QUERIES_DISPLAY_PLAIN_TEXT && Validator.isNotNull(answer)) {
answer = Portal.TEMP_OBFUSCATION_VALUE;
}
%>

<aui:input autocomplete='<%= PropsValues.COMPANY_SECURITY_PASSWORD_REMINDER_QUERY_FORM_AUTOCOMPLETE ? "on" : "off" %>' label="answer" maxlength="<%= ModelHintsConstants.TEXT_MAX_LENGTH %>" name="reminderQueryAnswer" size="50" type='<%= PropsValues.USERS_REMINDER_QUERIES_DISPLAY_PLAIN_TEXT ? "text" : "password" %>' value="<%= answer %>" />
</clay:sheet-section>

<aui:script sandbox="<%= true %>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Portal;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.struts.Action;
Expand Down Expand Up @@ -87,7 +88,6 @@ protected void updateReminderQuery(
AuthTokenUtil.checkCSRFToken(
httpServletRequest, UpdateReminderQueryAction.class.getName());

long userId = PortalUtil.getUserId(httpServletRequest);
String question = ParamUtil.getString(
httpServletRequest, "reminderQueryQuestion");
String answer = ParamUtil.getString(
Expand All @@ -98,7 +98,10 @@ protected void updateReminderQuery(
httpServletRequest, "reminderQueryCustomQuestion");
}

UserServiceUtil.updateReminderQuery(userId, question, answer);
if (!answer.equals(Portal.TEMP_OBFUSCATION_VALUE)) {
UserServiceUtil.updateReminderQuery(
PortalUtil.getUserId(httpServletRequest), question, answer);
}
}

}
10 changes: 9 additions & 1 deletion portal-web/docroot/html/portal/update_reminder_query.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ if (referer.equals(themeDisplay.getPathMain() + "/portal/update_reminder_query")
</div>
</c:if>

<aui:input autocomplete="off" cssClass="reminder-query-answer" label="answer" maxlength="<%= ModelHintsConstants.TEXT_MAX_LENGTH %>" name="reminderQueryAnswer" showRequiredLabel="<%= false %>" size="50" type="text" value="<%= user.getReminderQueryAnswer() %>">
<%
String answer = user.getReminderQueryAnswer();
if (!PropsValues.USERS_REMINDER_QUERIES_DISPLAY_PLAIN_TEXT && Validator.isNotNull(answer)) {
answer = Portal.TEMP_OBFUSCATION_VALUE;
}
%>

<aui:input autocomplete="off" cssClass="reminder-query-answer" label="answer" maxlength="<%= ModelHintsConstants.TEXT_MAX_LENGTH %>" name="reminderQueryAnswer" showRequiredLabel="<%= false %>" size="50" type='<%= PropsValues.USERS_REMINDER_QUERIES_DISPLAY_PLAIN_TEXT ? "text" : "password" %>' value="<%= answer %>">
<aui:validator name="required" />
</aui:input>
</aui:fieldset>
Expand Down

0 comments on commit 5e2da78

Please sign in to comment.