掲示板

Custom Login Portlet in Liferay 6.1 by extending login portlet using hooks

11年前 に Ugandhar Reddy によって更新されました。

Custom Login Portlet in Liferay 6.1 by extending login portlet using hooks

Junior Member 投稿: 25 参加年月日: 11/11/21 最新の投稿
Hi All,

I find difficulties to write my custom login portlet, But at last i found solution.
It may be helpful to someone else.
In liferay 6.1 we can extend the /login/login struts action using hooks and write our own logic and add extra UI elements and get the same.
1. Define the struts action in liferay-hooks.xml

<struts-action>
<struts-action-path>/login/login</struts-action-path>
<struts-action-impl>com.sample.hook.CustomLoginAction</struts-action-impl>
</struts-action>
2. Extend liferay login.jsp and write your own logic and elements, but login and password input text fields should be present.

<custom-jsp-dir>/custom_jsps</custom-jsp-dir>

3. define Portal.properties in hooks project like below.
auth.public.paths=/login/login

4. Write your CustomLoginAction class like below by calling original Login struts action.

public class CustomLoginAction extends BaseStrutsPortletAction {

@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

// This will call the Liferay default Login portlet and authenticate the liferay portal.
originalStrutsPortletAction.processAction(originalStrutsPortletAction,portletConfig, actionRequest, actionResponse);

// if you added any extra inputs in login.jsp
String language = ParamUtil.getString(actionRequest, "language");
String redirect = ParamUtil.getString(actionRequest, "redirect");
// you can provide any private page friendly url to redirect like below.
actionResponse.sendRedirect("/group/proj/home");
}

@Override
public String render(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, RenderRequest renderRequest,
RenderResponse renderResponse) throws Exception {

return originalStrutsPortletAction.render(originalStrutsPortletAction,
portletConfig, renderRequest, renderResponse);
}

}
thumbnail
11年前 に Bart Simpson によって更新されました。

RE: Custom Login Portlet in Liferay 6.1 by extending login portlet using ho

Liferay Master 投稿: 522 参加年月日: 11/08/29 最新の投稿
You can also create a wiki page for sharing information.
7年前 に Jaimin Patel によって更新されました。

RE: Custom Login Portlet in Liferay 6.1 by extending login portlet using ho

New Member 投稿: 1 参加年月日: 13/12/04 最新の投稿
This will redirect the user even if authentication fails which will be invalid.
Do you have any solution for this?