Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why
« Back to Configuring

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! :)

0 Attachments
115884 Views
Average (1 Vote)
The average rating is 4.0 stars out of 5.
Comments
Threaded Replies Author Date
Hi anyway has implemented own login portlet i... Hello Hello Hello August 8, 2008 2:47 AM
How do you change the login itself? I want to... paul a adams March 6, 2009 3:29 PM
Paul, This property should do it. # #... Amos Fong March 11, 2009 2:09 PM
Hi, If one wishes to add more portlets or... Raja Nagendra Kumar September 17, 2009 5:29 AM
Raja, Right now, I'm doing a login page. As... Anne D C September 21, 2009 3:49 AM
How can I disable requirest of authentication... Marco Bolzan September 24, 2009 3:51 AM
"...The portal will also use that page when an... Dan Grossen May 12, 2010 11:22 AM
It seems such redirection occurs in 5.2.3 in... Alex . July 14, 2010 4:54 AM
I set up a virtual host for the private pages... Matthew O Smith December 8, 2010 3:13 PM
I set auth.login.portlet.name=mylogin does't work lv yulin October 27, 2010 2:45 AM
Hi, I am trying to create a Custom Login Page... Piyush Khandelwal December 30, 2012 11:14 PM
Hi, I tried to look for a wiki version 6.1.1... Achmed Tyrannus Albab February 25, 2013 2:17 AM

Hi anyway has implemented own login portlet i want similar scenario
Posted on 8/8/08 2:47 AM.
How do you change the login itself? I want to use the screen name instead of the email. How would one do that?
Posted on 3/6/09 3:29 PM.
Paul,

This property should do it.

#
# The portal can authenticate users based on their email address, screen
# name, or user id.
#
#company.security.auth.type=emailAddress
company.security.auth.type=screenName
#company.security.auth.type=userId
Posted on 3/11/09 2:09 PM in reply to paul a adams.
Hi,

If one wishes to add more portlets or contents to the login page/register page (say some journal articles etc), how does one go about it.

I understand there must be some page id in which login portlet/register portlet would get rendered. How do identify such page id. May be if you could talk about these id's for standard portlets available for customization in extension environment, that would be nice value.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
Posted on 9/17/09 5:29 AM in reply to Amos Fong.
Raja,

Right now, I'm doing a login page. As far as I could understand, you want to make a "portlet" page with the login portlet and another portlet in it, right? If you make a new portlet page and named "login" (look in the URL friendly), you will be able to put journal content in it, as well as the login portlet. Then, Liferay will redirect you to that page where you will need to login.

Still, I'm unable to redirect the "sign in" URL...
I wish this would help (sorry, I'm not good writting in english).
Posted on 9/21/09 3:49 AM in reply to Raja Nagendra Kumar.
How can I disable requirest of authentication for example for blog page /web/mysite/blog?
I use social office 1.5b
Posted on 9/24/09 3:51 AM in reply to Anne D C.
"...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."

I'm using 5.2.3 and it still users the /home page in this scenario
Posted on 5/12/10 11:22 AM.
It seems such redirection occurs in 5.2.3 in only case if virtual host is defined for the community
Posted on 7/14/10 4:54 AM in reply to Dan Grossen.
I set auth.login.portlet.name=mylogin does't work
Posted on 10/27/10 2:45 AM.
I set up a virtual host for the private pages and is still goes to /home with the default login page displayed.
Posted on 12/8/10 3:13 PM in reply to Alex ..
Hi,

I am trying to create a Custom Login Page which include following:
1)EmailAddress
2)Password
3)Captcha

I used Hook for this .
Captcha code is visible after adding code in Jsp.
But I am unable to validate this captcha on Sign In.

I extend LoginAction Class for writing the java code.

Thanks
Piyush
Posted on 12/30/12 11:14 PM.
Hi,

I tried to look for a wiki version 6.1.1 but couldn't find any.
So please excuse me if i'm in the wrong thread.

I have few sites under one portal, and have login pages created such as:
a.alpha.com/login
b.alpha.com/login
c.alpha.com/login
...

What i am trying to do here is to disallow members from c.alpha.com logging in cia a.alpha.com/login .

Currently the users from other sites can login at any of these /login pages eventhough they couldnt edit anything since i have set them roles restrictions.

I do not want to change my /login page name to something else if thats your suggestion.
I just need to block user from different Site to log in through other Site login page.

I hope i am clear enough.

Terima Kasih.
Posted on 2/25/13 2:17 AM.