Customizing Default Landing Page Per User
Default Landing Page is where user is automatically redirected after the successful login into the Webspace server. There is a configuration parameter "default.landing.page.path" which can be set for portal wide landing page for every user. To configure a system wide landing page, configure following parameters in portal-ext.properties.
auth.forward.by.last.path=true default.landing.page.path=/web/guest/login
The above configuration lands users to "/web/guest/login" page after successful authentication. If the Webspace URL is http://localhost:8080 then the user is redirected to http://localhost:8080/web/guest/login.
Things become interesting when it is required to configure a landing page per user. The webspace server also has a configuration parameter "login.events.post" which can take a comma separated list of Java classes that will be invoked after the successful login by a user. The default Landing Page behavior is actually, part of the post login event.
This document provides with a sample that would allow the Webspace administrator to provision a user with default landing page (this could be potentially a private page of a community) per user. Also, this sample includes a Java class that would be included in the "login.events.post" list. The Java class MyLandingPage would read the custom attribute "landingpage" which would point to a community's private/public page (or any other page).
To Install and Configure
- Download the MyLandingPage.java
- Build the jar using Netbeans portal pack by selecting Java application project with Webspace libraries. The portal-impl.jar also required which is available under WEB-INF/lib directory of the GlassFish domain's webspace application directory (GF_DIR/domains/domain1/applications/j2ee-modules/webspace/WEB-INF/lib).
- Copy the jar file into webspace customs directory <install_root>/var/webspace/war-workspace/customs/webspace/WEB-INF/lib
- Add the following line to portal-ext.properties file at <install_root>/var/webspace/war-workspace/customs/webspace/WEB-INF/classes. If portal-ext.properties exist, then append to the file, else create it.
login.events.post=com.liferay.portal.events.LoginPostAction,com.sample.MyLandingPage
- Build and install the update webspace.war by running "ant -f synchronize.xml"
- Restart the Webspace Server.
- Using control panel (as "admin" user) add a text based custom attribute "landingpage" under "Users" option. Grant "View" permission to "Guest".
- Edit a user and assign the custom attribute to a community's private page. (for example /group/customer)
- Test the Login for user.
In this sample, if the user is not provisioned with "landingpage" attribute then the portal's default landing page becomes applicable.