ForgotPasswordAction をカスタマイズする解決策はありますか? 私の最終的な目標は、ユーザーがユーザー名または電子メールの両方を入力して、忘れたパスワードを取得できるようにすることです。ForgotPassword.java の getUser(ActionRequest request) メソッドを次のようにオーバーライドしました。
protected User getUser(ActionRequest actionRequest)
throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
WebKeys.THEME_DISPLAY);
//CUSTOM
String fgtPass = ParamUtil.getString(actionRequest, "fgtpass");
String authType = null;
if (Validator.isNull(authType)) {
Company company = PortalUtil.getCompany(actionRequest);
authType = company.getAuthType();
}
User user = null;
if ( fgtPass.indexOf("@") != -1 && fgtPass.indexOf(".") != -1 ) {
//If the login looks like an email, use the email authType constant.
authType = CompanyConstants.AUTH_TYPE_EA;
user = UserLocalServiceUtil.getUserByEmailAddress(
themeDisplay.getCompanyId(), fgtPass);
} else {
//If it doesn't look like an email, use the screen name authType constant.
authType = CompanyConstants.AUTH_TYPE_SN;
user = UserLocalServiceUtil.getUserByScreenName(
themeDisplay.getCompanyId(), fgtPass);
}
//End CUSTOM
return user;
}
}
これにより、最初のパスワードを忘れた画面でスクリーン名または電子メールに基づいてユーザーを認証できますが、リマインダー クエリ ページに移動すると、ユーザーを処理できません。fgtPassフィールドは最初のパスワードを忘れた画面にのみ存在し、クエリページには存在しないため、私はできないと確信しています。このユーザーを永続化する方法はありますか? 対応する .jsp は次のとおりです。
<%
User user2 = (User)request.getAttribute(ForgotPasswordAction.class.getName());
if (Validator.isNull(authType)) {
authType = company.getAuthType();
System.out.println(authType);
}
if (user2 == null) {
System.out.println("User is null.");
} else {
System.out.println(user2.getScreenName());
}
%>
<portlet:actionURL var="forgotPasswordURL">
<portlet:param name="saveLastPath" value="0" />
<portlet:param name="struts_action" value="/login/forgot_password" />
</portlet:actionURL>
<aui:form action="<%= forgotPasswordURL %>" method="post" name="fm">
<portlet:renderURL var="redirectURL" />
<aui:input name="redirect" type="hidden" value="<%= redirectURL %>" />
<liferay-ui:error exception="<%= CaptchaTextException.class %>" message="text-verification-failed" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message='<%= "the-" + TextFormatter.format(authType, TextFormatter.K) + "-you-requested-is-not-registered-in-our-database" %>' />
<liferay-ui:error exception="<%= RequiredReminderQueryException.class %>" message="you-have-not-configured-a-reminder-query" />
<liferay-ui:error exception="<%= SendPasswordException.class %>" message="your-password-can-only-be-sent-to-an-external-email-address" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" message="please-enter-a-valid-email-address" />
<liferay-ui:error exception="<%= UserReminderQueryException.class %>" message="your-answer-does-not-match-what-is-in-our-database" />
<aui:fieldset>
<c:choose>
<c:when test="<%= user2 == null %>">
<% System.out.println("Enter Test"); %>
<%
String loginParameter = null;
if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
loginParameter = "emailAddress";
System.out.println(loginParameter);
}
else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
loginParameter = "screenName";
System.out.println(loginParameter);
}
else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
loginParameter = "userId";
System.out.println(loginParameter);
}
String loginValue = ParamUtil.getString(request, loginParameter);
%>
<aui:input name="step" type="hidden" value="1" />
<aui:input label="login-screen-name-or-email" name="fgtpass" size="30" type="text" value="<%= loginValue %>" />
<aui:button-row>
<aui:button type="submit" value='<%= PropsValues.USERS_REMINDER_QUERIES_ENABLED ? "next" : "send-new-password" %>' />
</aui:button-row>
<% System.out.println("The login value is: " + loginValue); %>
</c:when>
<c:when test="<%= (user2 != null) && Validator.isNotNull(user2.getEmailAddress()) %>">
<aui:input name="step" type="hidden" value="2" />
<%
if (user2!=null) {
System.out.println("Step 2 " + authType);
}
%>
<aui:input name="emailAddress" type="hidden" value="<%= user2.getEmailAddress() %>" />
<% System.out.println(user2.getEmailAddress()); %>
<c:if test="<%= Validator.isNotNull(user2.getReminderQueryQuestion()) && Validator.isNotNull(user2.getReminderQueryAnswer()) %>">
<div class="portlet-msg-info">
<%= LanguageUtil.format(pageContext, "a-new-password-will-be-sent-to-x-if-you-can-correctly-answer-the-following-question", user2.getEmailAddress()) %>
</div>
<% System.out.println(user2.getReminderQueryAnswer()); %>
<aui:input label="<%= user2.getReminderQueryQuestion() %>" name="answer" type="text" />
</c:if>
<c:choose>
<c:when test="<%= PropsValues.USERS_REMINDER_QUERIES_REQUIRED && !user2.hasReminderQuery() %>">
<div class="portlet-msg-info">
<liferay-ui:message key="the-password-cannot-be-reset-because-you-have-not-configured-a-reminder-query" />
</div>
</c:when>
<c:otherwise>
<c:if test="<%= PropsValues.CAPTCHA_CHECK_PORTAL_SEND_PASSWORD %>">
<portlet:actionURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>" var="captchaURL">
<portlet:param name="struts_action" value="/login/captcha" />
</portlet:actionURL>
<liferay-ui:captcha url="<%= captchaURL %>" />
</c:if>
<aui:button-row>
<aui:button type="submit" value='<%= company.isSendPasswordResetLink() ? "send-password-reset-link" : "send-new-password" %>' />
</aui:button-row>
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
<div class="portlet-msg-alert">
<liferay-ui:message key="the-system-cannot-send-you-a-new-password-because-you-have-not-provided-an-email-address" />
</div>
</c:otherwise>
</c:choose>
</aui:fieldset>
</aui:form>
<liferay-util:include page="/html/portlet/login/navigation.jsp" />
<aui:script>
Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace /><%= (user2 == null) ? "emailAddress" : "answer" %>);
</aui:script>
手がかりはありますか?