1.requirement
We use liferay as portal container, our system support multi-company by difference community; we hope the page redirect the community's private page after login.
2.solution
step.1
create and edit the liferay configuration file
portal-ext.properties auth.forward.by.last.path=true
copy this file to ${liferay_home}/server/default/deploy/ROOT.war/WEB-INF/classes/ portal-ext.properties
This will overwrite the "auth.forward.by.last.path" value in portal.properties which is set to "false" by default. Now, after users login, they will be redirected to the last page they were at, instead of their own private community.
step.2
if we want to customize the redirect even, we need to add and edit one more file:
com.liferay.portal.events.LoginPostAction.java
Show code:
compile the java file and copy the LoginPostAction.class to server/default/deploy/ROOT.war/WEB-INF/classes/com/liferay/portal/events/LoginPostAction.class
step.3
We will overwrite a couple values in "portal.properties" by editing our "portal-ext.properties" file. Add these 2 lines of code:
auth.forward.by.last.path=true
login.events.post=com.liferay.portal.events.LoginPostAction,com.liferay.portal.events.CustomLoginPostAction