Fórum

Autologin after user has created account without going to sign in page.

Abdulbasit Shaikh, modificado 9 Anos atrás.

Autologin after user has created account without going to sign in page.

New Member Postagens: 18 Data de Entrada: 16/05/13 Postagens Recentes
Hi,

I want to make the user login after user has created the account successfully without going to the sign in page. For that I searched a lot and I got the solution that I have to use the LoginUtil class of portal-impl.jar. Inside that login method is there using which I can achieve this functionality.

Now my problem is, I have created ext and I have override the LoginUtil class inside my ext. There is no change inside LoginUtil class as I just want to use it and no modification requires.

After that I have one portlet in which simple form is there. On button click of that form, I am accessing LoginUtil class in java class. Please find the code snippet for the same as follows:

public void createAccount(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {

_log.info("-->Account creation start");

try {
LoginUtil.login(PortalUtil.getHttpServletRequest(actionRequest), PortalUtil.getHttpServletResponse(actionResponse), "test@liferay.com", "test", false, null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

I have add all the jars of tomcat/lib, tomcat/lib/ext and tomcat-7.0.42\webapps\ROOT\WEB-INF\lib as dependency jars. So portal-impl.jar has also added and all my ext jars also added as dependency jars. So it is able to find LoginUtil class compile time.

But when I run my portlet, it gives me an exception as

javax.portlet.PortletException: java.lang.NoClassDefFoundError: com/liferay/portlet/login/util/LoginUtil

Please help me out to achieve this functionality. Thanks in advance.

Thanks and Regards,
Abdulbasit F Shaikh.
thumbnail
Grzegorz Kucner, modificado 9 Anos atrás.

RE: Autologin after user has created account without going to sign in page.

Junior Member Postagens: 39 Data de Entrada: 26/01/09 Postagens Recentes
Hi,

LoginUtil is a class from portal-impl package. You can invoke login method in 3 different ways.

1. Use portal classloader to load LoginUtil class and then invoke login method. Portal classloader can be accesed via PortalClassLoaderUtil.getClassLoader() method.

2. Move all required libraries from /webapps/ROOT/WEB-INF/lib to tomcat/lib/ext to make then accesible from plugins.

3. Reimplement login method in your portlet wich is best in my opinion.

Regards
Grzegorz
Abdulbasit Shaikh, modificado 9 Anos atrás.

RE: Autologin after user has created account without going to sign in page.

New Member Postagens: 18 Data de Entrada: 16/05/13 Postagens Recentes
Hi Grzegorz Kucner,

Thanks for the quick reply. I will just try and let you know.

Thanks and Regards,
Abdulbasit F Shaikh.