Foren

Custom Login portlet to call Liferay API and redirect to Private page

Ugandhar Reddy, geändert vor 12 Jahren.

Custom Login portlet to call Liferay API and redirect to Private page

Junior Member Beiträge: 25 Beitrittsdatum: 21.11.11 Neueste Beiträge
Hi All

In 4.3 we have used ext environment and calling LoginUtil.login() method from portal-impl.jar we are able to authenticate liferay and forwarding to Liferay private page from custom login portlet.

From the forums we found that it's not good practice to use portal-impl.jar, need to use portal-service.jar so in liferay 6.0.6 we have started using plugins sdk and we are calling UserLocalServiceUtil.authenticateByScreenName() from portal-service.jar and trying to forward to liferay private page which we created but it stays back in the same public login page and the url will be changed to http://localhost:8080/web/test/login?p_p_id=58&p_p_lifecycle=0&_58_redirect=%2Fgroup%2Ftest%2Fhome .

please find the below processAction code for the same.

int authResult = 0;
long companyId=1;
Map headerMap = new HashMap();
Company company = PortalUtil.getCompany(req);
Map parameterMap = req.getParameterMap();
authResult=UserLocalServiceUtil.authenticateByScreenName(company.getCompanyId(), username, password, headerMap, parameterMap);
if(authResult==1){
res.sendRedirect("/group/test/home");
}else{
req.setAttribute("JSP_LOGIN", "/WEB-INF/jsps/login/ack.jsp");
}

NOTE: As per my understanding Hooks will be used to customize the liferay specific code, in our case we just want to authenticate liferay login API to view private pages.
Venkat Koppavolu, geändert vor 12 Jahren.

RE: Custom Login portlet to call Liferay API and redirect to Private page

Junior Member Beiträge: 85 Beitrittsdatum: 26.07.10 Neueste Beiträge
Hi Ugandhar,

You should use hooks to customize the liferay authentication process while user login.
Check portal.properties
##
## Authentication Pipeline
##
#auth.pipeline.pre=com.customportal.security.auth.CustomAuth

CustomAuth.java contains the logic how user should authenticated and you can add your own methods too, this class will be invoked and give authResult value (1 or 0).

Hope this will help you

Thanks,
Venkat
thumbnail
Sharana Basavaraj Ballari, geändert vor 12 Jahren.

RE: Custom Login portlet to call Liferay API and redirect to Private page

Regular Member Beiträge: 139 Beitrittsdatum: 10.09.07 Neueste Beiträge
Hi Ugandhar,

You can write a event based hook such as post login to forward users to the specific pages. Before that you can write a Autologin hook to login the user and configure

auth.forward.by.last.path=true
default.landing.page.path=/web/guest/home

in portal-ext.properties file. Hooks allows you to customise the functionality bit you wanted and rest being executed in core liferay way.

HTH,
Sharan