Forum

Accueil » Liferay Portal » English » 3. Development

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
Shiho Pingali
Redirect on failed login
7 août 2012 12:04
Réponse

Shiho Pingali

Rang: New Member

Publications: 12

Date d'inscription: 20 décembre 2011

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?
David H Nebinger
RE: Redirect on failed login
7 août 2012 13:45
Réponse

David H Nebinger

Rang: Liferay Legend

Publications: 6699

Date d'inscription: 1 septembre 2006

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
RE: Redirect on failed login
9 août 2012 06:47
Réponse

Shiho Pingali

Rang: New Member

Publications: 12

Date d'inscription: 20 décembre 2011

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:
1<%= SessionErrors.contains((PortletRequest)request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST), "com.liferay.portal.security.auth.AuthException")  %>
Andrey N
RE: Redirect on failed login
15 juillet 2013 08:35
Réponse

Andrey N

Rang: New Member

Publications: 1

Date d'inscription: 15 juillet 2013

Publications Récentes

Another option is to extend LoginAction (via Ext or Hook). In case of Ext:

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

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