Forums de discussion

Redirect on failed login

Shiho Pingali, modifié il y a 11 années.

Redirect on failed login

New Member Publications: 12 Date d'inscription: 20/12/11 Publications récentes
I would like to redirect some failed login to outside page (not liferay login page). We use LDAP authentication required and authType is screenname. Could someone help me with the following questions?

1. Is there a easy way to do this in login.jsp
2. I created a class to implement AuthFailure but it's not working when user inputs wrong screen name. If password is not correct, AuthenticationException is thrown in LDAPAuth and is going to my custom AuthFailure class but not when screen name doesn't exist, it doesn't go to my custom AuthFailure class. Which authenticator is throwing AuthException in this case? How can I catch this?
3. Which class can I override to do redirect on failed login?
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Redirect on failed login

Liferay Legend Publications: 14914 Date d'inscription: 02/09/06 Publications récentes
You don't have to do anything to login.jsp.

The liferay authentication system can handle login by screen name. You just have to configure it in the control panel.

A valid screen name must exist in the Liferay database. If it doesn't exist there, LDAP is never invoked to handle the authentication.

Liferay typically doesn't do anything on failed logins but report the failure. This allows the user time to fix their login (in this case screen name) or password. Basically your change would only give the user one chance to get it right before getting redirected away, and is not something your users would like.
Shiho Pingali, modifié il y a 11 années.

RE: Redirect on failed login

New Member Publications: 12 Date d'inscription: 20/12/11 Publications récentes
Thank you for your reply. I decided to check for errors in login.jsp
If anyone is interested, the following code in jsp page will check if AuthException is thrown during login:
<%= SessionErrors.contains((PortletRequest)request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST), "com.liferay.portal.security.auth.AuthException")  %>
Andrey Nemchenko, modifié il y a 10 années.

RE: Redirect on failed login

New Member Envoyer: 1 Date d'inscription: 15/07/13 Publications récentes
Another option is to extend LoginAction (via Ext or Hook). In case of Ext:

package com.company.portlet.login.action;
public class MyLoginAction extends com.liferay.portlet.login.action.LoginAction {
  @Override
  public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
                            ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    super.processAction(mapping, form, portletConfig, actionRequest, actionResponse);
    String redirect = "/url";
    actionResponse.sendRedirect(redirect);
  }
}

struts-config.ext.xml:
<action path="/login/login" type="com.company.portlet.login.action.MyLoginAction">
    <forward name="portlet.login.login" path="portlet.login.login" />
    <forward name="portlet.login.login_redirect" path="portlet.login.login_redirect" />
 </action>