
Custom Portal Login Page
By default when the user was in any place of the portal clicks the "Sign in" link he is shown an static portal login page (located at /c/portal/login). While it's possible to create your own customized login page using the available portlets, the user is not redirected to that page when clicking the "Sign in" button. This article explains how to change that in Liferay 5.0
Customizing the global portal page #
It is possible to let the portal know that a given page should act as the portal login page by setting a property in portal(-ext).properties with the property auth.login.url. For example to set the home page of the guest community:
auth.login.url=/web/guest/home
After this value is set, every time a user clicks "Sign in" he will be redirected to the specified page. The portal will also use that page when an anonymous user tries to access a page that requires authentication and is to be redirected to the login page.
Using a different login page per community or organization #
Sometimes you want even more customization capabilities. In particular many people use Liferay's ability to have multiple communities (whenever I say community from now on, include organizations within the term) with separate websites and some users just know about one specific community. In this case it's often desired to keep the user within that community/organization to login instead of going to a portal wide page.
Starting with version 5.0 this is now possible in a very easy way. Just create a new page within the community and give it the friendly URL path /login That's it. The portal will detect that such a page exists and will use it as a login page when the user clicks sign in from within that community. Easy right?
The actual friendly URL path is configurable in portal(-ext).properties so you can change it to whatever you want:
auth.login.community.url=/login
Note that for communities doesn't have such a page, the global login page configured in the previous section, or the default portal login page, will be automatically used instead.
Prior to 5.2.0 there has been limitation in this feature. When the user navigated to a page within the community that requires login, the old portal login would still be used. This was solved version 5.2.0. If you're operating an older version, take a look at LPS-342
Advanced #
Using your own login portlet #
Some advanced Liferay deployments include their own login portlet instead of the one bundled with Liferay. When this is done and the login page is customized as explained in this article the user will not be automatically redirected to the page where he was going to prior to login. Note that this only applies when the user is automatically redirected to the login page when trying to navigate to a protected page.
The reason is that the portlet doesn't have access to the redirect parameter that is used to signal the login portlet which page was the using trying to access to. The solution is to let the portal know which is the id of the custom login portlet so that it can make the redirect parameter available to it. This is done through a third property whose default value is:
auth.login.portlet.name
Conclusion #
That's it. This should cover all the needed cases in a quite easy way. Enjoy! :)