这可以通过挂钩 login.jsp 并覆盖 liferay-ui:error 标记中的 AuthException 消息来完成,如下所示。
Boolean isMaxFailedLoginAttempt = false;
PortletRequest portletRequest = (PortletRequest)request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
if(SessionErrors.contains(portletRequest, AuthException.class.getName())) {
User u = UserLocalServiceUtil.getUserByEmailAddress(company.getCompanyId(), login);
if(u != null) {
if(u.getFailedLoginAttempts() == 5) {
isMaxFailedLoginAttempt = true;
}
}
}
if(isMaxFailedLoginAttempt) {
%>
<liferay-ui:error exception="<%= AuthException.class %>" message="The username or password you entered is incorrect; another incorrect login will temporarily lock your account. Please use forgot password link to reset the password." />
<%
} else {
%>
<liferay-ui:error exception="<%= AuthException.class %>" message="The username or password you entered is incorrect. Please try again." />
<%
}
%>
`