Search code examples
authenticationliferay

Liferay auto login


I must use Liferay 5.2.3 and tomcat-5.5.27

I have to login user programmatically. I create a portlet and a file "view.jsp"

I found and tried this code:

String username = String.valueOf(user.getUserId());
String password = user.getPassword();

HttpSession session = request.getSession();
session.setAttribute("j_username", username);
session.setAttribute("j_password", password);
session.setAttribute("j_remoteuser", username);

I find the user by id but i'm not signed in liferay. What am i missing?


Solution

  • Sorry but it's totally wrong way.

    You need an hook plugin, have to implement an AutoLogin based class with a custom portal.properties to setup auto.login.hooks property.

    Follow this discussion: https://community.liferay.com/it/forums/-/message_boards/message/114134