Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Login Error Messages
Looking at the Liferay source, portal-web/docroot/html/portlet/login/login.jsp has different error messages depending on the exception thrown.
However, "com.liferay.portal.security.auth.Authenticator" only throws an "AuthException", and prevents any class that implements it from bubbling up a different exception bubble up.
Seems seems like either a bug or an inflexible design.
Are there any thoughts out there as to why this is the case?
If there are no good reason I'd like to submit/recommend changes to com.liferay.portal.security.auth.Authenticator that would allow a more flexible custom authentication experience.
Also for for reference the following thread has some information as well. Changing Login Error Messages
<liferay-ui:error exception="<%= AuthException.class %>" message="authentication-failed" />
<liferay-ui:error exception="<%= CookieNotSupportedException.class %>" message="authentication-failed-please-enable-browser-cookies" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="please-enter-a-valid-login" />
<liferay-ui:error exception="<%= PasswordExpiredException.class %>" message="your-password-has-expired" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" message="please-enter-a-valid-login" />
<liferay-ui:error exception="<%= UserLockoutException.class %>" message="this-account-has-been-locked" />
<liferay-ui:error exception="<%= UserPasswordException.class %>" message="please-enter-a-valid-password" />
<liferay-ui:error exception="<%= UserScreenNameException.class %>" message="please-enter-a-valid-screen-name" />
However, "com.liferay.portal.security.auth.Authenticator" only throws an "AuthException", and prevents any class that implements it from bubbling up a different exception bubble up.
Seems seems like either a bug or an inflexible design.
Are there any thoughts out there as to why this is the case?
If there are no good reason I'd like to submit/recommend changes to com.liferay.portal.security.auth.Authenticator that would allow a more flexible custom authentication experience.
Also for for reference the following thread has some information as well. Changing Login Error Messages
Login failures will typically show two failures, the first is the 'invalid data' or something, the second is the valuable one from the language bundle.
I used CSS to disable the display of the first one (since it has little if any value) and only show the good one.
I used CSS to disable the display of the first one (since it has little if any value) and only show the good one.
Hello,
I'm having the same problem : I'm implementing a custom Authenticator :
I need to check the email and check a custom table.
Then, if check fails, I have to ask another authentication value to the user, this is not an error,
The user must have a custom message when my custom Authenticator fails.
How to do bring this information to the portlet/login/login.jsp ?
Thank you !
I'm having the same problem : I'm implementing a custom Authenticator :
public class PreAuthAction implements Authenticator {
@Override
public int authenticateByEmailAddress(...) {
if (... custom call to a database ...) {
... There I need to throw or return some thing in order the user receives a custom message in login.jsp ...
} else {
return Authenticator.SUCCESS;
}
}
I need to check the email and check a custom table.
Then, if check fails, I have to ask another authentication value to the user, this is not an error,
The user must have a custom message when my custom Authenticator fails.
How to do bring this information to the portlet/login/login.jsp ?
Thank you !
I've tried several ways but ended up with the Java reflection.
So you basically need to extend AuthException class in your hook:
As your code is in the hook, but JSP served from ROOT, you have to use reflection to access it. As no params are passed, the final code is not so complex:
Jan
So you basically need to extend AuthException class in your hook:
public class MyAuthException extends AuthException {
public MyAuthException() {
super();
}
}
As your code is in the hook, but JSP served from ROOT, you have to use reflection to access it. As no params are passed, the final code is not so complex:
<%@page import="com.liferay.portal.kernel.bean.PortletBeanLocatorUtil" %>
<%@page import="java.lang.reflect.Method" %>
...
<%
ClassLoader classLoader = PortletBeanLocatorUtil.getBeanLocator("my-hook").getClassLoader();
Class myAuthExceptionClass = classLoader.loadClass("com.company.hook.MyAuthException");
%>
<liferay-ui:error exception="<%= myAuthExceptionClass %>" message="my-error-msg" />
Jan
Hi,
How to add MyAuthException in implemented authenticateByScreenName( ) method of CustomAthenticator class.
I tried with above code , I was unable get the myAuthException message.
and more over <%@page import="com.liferay.portal.kernel.bean.PortletBeanLocatorUtil" %> not imported in login.jsp
Hi All,
Can any one help me out.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™