Fórum

Login Error Messages

thumbnail
Michael Charles, modificado 11 Anos atrás.

Login Error Messages

New Member Postagens: 15 Data de Entrada: 20/01/11 Postagens Recentes
Looking at the Liferay source, portal-web/docroot/html/portlet/login/login.jsp has different error messages depending on the exception thrown.

<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
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Login Error Messages

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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.
Vincent Pradeilles, modificado 9 Anos atrás.

RE: Login Error Messages

New Member Postagens: 7 Data de Entrada: 29/10/14 Postagens Recentes
Hello,

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 !
Jan Tošovský, modificado 6 Anos atrás.

RE: Login Error Messages

Liferay Master Postagens: 566 Data de Entrada: 22/07/10 Postagens Recentes
I've tried several ways but ended up with the Java reflection.

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:

&lt;%@page import="com.liferay.portal.kernel.bean.PortletBeanLocatorUtil" %&gt;
&lt;%@page import="java.lang.reflect.Method" %&gt;
...
&lt;%
    ClassLoader classLoader = PortletBeanLocatorUtil.getBeanLocator("my-hook").getClassLoader();
    Class myAuthExceptionClass = classLoader.loadClass("com.company.hook.MyAuthException");
%&gt;

<liferay-ui:error exception="<%= myAuthExceptionClass %>" message="my-error-msg" />


Jan
Chanakya P, modificado 1 Ano atrás.

RE: Login Error Messages

Junior Member Postagens: 72 Data de Entrada: 17/02/14 Postagens Recentes

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

 

 

Chanakya P, modificado 1 Ano atrás.

RE: Login Error Messages

Junior Member Postagens: 72 Data de Entrada: 17/02/14 Postagens Recentes

Hi All,

 

Can any one help me out.