Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
redirect to the user's private page after login jacky hung October 2, 2008 8:36 PM
RE: redirect to the user's private page after login Tobias Amon October 2, 2008 11:49 PM
RE: redirect to the user's private page after login Mario Muñoz October 3, 2008 1:25 AM
RE: redirect to the user's private page after login Shamsul Bahrin March 16, 2009 2:20 AM
RE: redirect to the user's private page after login Ali Shahrami July 1, 2010 10:34 AM
RE: redirect to the user's private page after login Danny Francisco September 28, 2010 4:58 PM
RE: redirect to the user's private page after login Rob Caljouw August 18, 2010 4:06 PM
RE: redirect to the user's private page after login Danny Francisco October 10, 2010 9:01 AM
RE: redirect to the user's private page after login Rob Caljouw October 10, 2010 9:31 AM
RE: redirect to the user's private page after login Danny Francisco October 11, 2010 6:29 AM
RE: redirect to the user's private page after login Rob Caljouw October 11, 2010 1:00 PM
RE: redirect to the user's private page after login Danny Francisco October 11, 2010 4:02 PM
RE: redirect to the user's private page after login Rob Caljouw October 11, 2010 7:28 PM
RE: redirect to the user's private page after login Ali Shahrami September 17, 2010 7:50 AM
RE: redirect to the user's private page after login Tomas Guido November 24, 2010 10:01 AM
RE: redirect to the user's private page after login Praveen P April 2, 2012 2:12 AM
RE: redirect to the user's private page after login Dhrutika Vyas April 2, 2012 5:58 AM
RE: redirect to the user's private page after login Tejas Kanani May 15, 2013 2:35 AM
RE: redirect to the user's private page after login Vipin Bardia July 9, 2015 3:32 AM
RE: redirect to the user's private page after login Aristide Cittadino October 8, 2015 1:58 AM
RE: redirect to the user's private page after login kunal hemrajani October 8, 2015 2:08 AM
RE: redirect to the user's private page after login Anuvab Ghosh July 18, 2016 4:03 AM
RE: redirect to the user's private page after login Tejas Kanani July 18, 2016 7:45 AM
RE: redirect to the user's private page after login Anuvab Ghosh July 18, 2016 10:38 PM
RE: redirect to the user's private page after login Tejas Kanani July 19, 2016 8:03 AM
jacky hung
redirect to the user's private page after login
October 2, 2008 8:36 PM
Answer

jacky hung

Rank: New Member

Posts: 8

Join Date: April 8, 2008

Recent Posts

now, by default, the user is show wiith the guest page after login, i have to click the "My place" --> private to navigate to the user's private page. how can i redirect the user to his private page directly after login?

i know in 5.1.1. there is "default.landing.page.path" in properties file, but know can i pass the user name in the ulr?

like /user/jacky/home is the jacky's private page url,

so is there anything i can set like : default.landing.page.path=/user/{username}/home

thanks
Tobias Amon
RE: redirect to the user's private page after login
October 2, 2008 11:49 PM
Answer

Tobias Amon

Rank: Liferay Master

Posts: 549

Join Date: August 8, 2007

Recent Posts

Hi,

it might work with the placeholder for the landing page. But I don't know the format.

Another way is to use the PostLoginAction which can be specified. Create a class extending the "Action" class.
In the "run" method you can put some code like this

1
2User user = req.getRemoteUser() // use liferay methods to get the user object having the userid from the "remoteUser"
3response.sendRedirect("/web/" + user.getUsername() + "/home");


that's it.

kind regards
Tobias
Mario Muñoz
RE: redirect to the user's private page after login
October 3, 2008 1:25 AM
Answer

Mario Muñoz

Rank: Junior Member

Posts: 43

Join Date: August 27, 2007

Recent Posts

Hi,

The recommended way to achieve this behaviour is modifying (or create your own) com.liferay.portal.events.DefaultLandingPageAction class. There is a good tutorial in Liferay wiki here:

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Customizing+the+default+page+after+login

You can get the user screenName (the parameter in the personal comunnity URL) with something like this:

1
2screenName = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request)).getScreenName();


Hope this helps.

Mario.
Shamsul Bahrin
RE: redirect to the user's private page after login
March 16, 2009 2:20 AM
Answer

Shamsul Bahrin

Rank: New Member

Posts: 1

Join Date: March 16, 2009

Recent Posts

FIRST, write this java code:


package com.liferay.portal.events;

import com.liferay.portal.kernel.events.Action;
import com.liferay.portal.kernel.util.*;
import com.liferay.portal.struts.LastPath;
import com.liferay.portal.util.*;
import com.liferay.portal.service.*;
import java.util.*;
import javax.servlet.http.*;

public class DefaultLandingPageAction extends Action {

public void run(HttpServletRequest request, HttpServletResponse response) {
try {
String screenName = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request)).getScreenName();
String path = "/web/" + screenName + "/home";
if (Validator.isNotNull(path)) {
LastPath lastPath = new LastPath(StringPool.BLANK, path, new HashMap<String, String[]>());
HttpSession session = request.getSession();
session.setAttribute(WebKeys.LAST_PATH, lastPath);
}
} catch ( Exception e ) {
e.printStackTrace();
}
}

}



THEN, in the portal-ext.properties, add this line:

login.events.post=com.liferay.portal.events.LoginPostAction,com.liferay.portal.events.DefaultLandingPageAction



DONE.....
Ali Shahrami
RE: redirect to the user's private page after login
July 1, 2010 10:34 AM
Answer

Ali Shahrami

Rank: Junior Member

Posts: 52

Join Date: July 31, 2009

Recent Posts

Shamsul Bahrin:

String screenName = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request)).getScreenName();
String path = "/web/" + screenName + "/home";



This path does not send user to his/her private page. The other issue that I have with screenName is that in most cases, the screenName from User is different than the actual user's friendlyURL that I believe comes from group table.

I have updated the following settings in portal-ext.properties and user is redirected to the private page. Default values are set to "true" and I set them to "false".
#
# Set this to true if users are forwarded to the last visited path upon
# successful login. If set to false, users will be forwarded to their
# default layout page.
#
auth.forward.by.last.path=false

#
# The login page reads a redirect by a parameter named "redirect". If this
# property is set to true, then users will be redirected to the given
# redirect path upon successful login. If the user does not have permission
# to view that page, then the rule set by the property
# "auth.forward.by.last.path" will apply.
#
# You can set the redirect manually from another application, by appending
# the "redirect" parameter in a url that looks like this:
# /c/portal/login?redirect=%2Fgroup%2Femployees%2Fcalendar. This url will
# redirect the user to the path "/group/employees/calendar" upon successful
# login.
#
auth.forward.by.redirect=false
Danny Francisco
RE: redirect to the user's private page after login
September 28, 2010 4:58 PM
Answer

Danny Francisco

Rank: New Member

Posts: 10

Join Date: December 12, 2008

Recent Posts

Hi Ali,

I tried your solution with 6.0.4. Still not redirecting to private page. What version of Liferay are you using ?
Rob Caljouw
RE: redirect to the user's private page after login
August 18, 2010 4:06 PM
Answer

Rob Caljouw

Rank: New Member

Posts: 14

Join Date: June 3, 2009

Recent Posts

Hi Danny,

I'm using Liferay 6.0.4 and setting the following:

auth.forward.by.last.path=false
auth.forward.by.redirect=false

worked for me as far as redirecting users to their private pages.

The problem I'm having is related to setting the virtual host. If the virtual host is set to localhost users are directed to their private page. When the virtual host is set to the domain name users are directed to <virtual-host-name>/home no matter what the auth.forward.* settings are.

If you, or anyone else, has any suggestions on how to direct users to their private page when the virtual host name is set I'd really appreciate hearing them.

Best regards.

RJC
Ali Shahrami
RE: redirect to the user's private page after login
September 17, 2010 7:50 AM
Answer

Ali Shahrami

Rank: Junior Member

Posts: 52

Join Date: July 31, 2009

Recent Posts

Danny Francisco:


I tried you solution with 6.0.4. Still not redirecting to private page. What version of Liferay are you using ?


This worked for me with Liferay 5.2.3
Danny Francisco
RE: redirect to the user's private page after login
October 10, 2010 9:01 AM
Answer

Danny Francisco

Rank: New Member

Posts: 10

Join Date: December 12, 2008

Recent Posts

Hi Rob,

I still couldn't solve this. Did you have any luck?

Best Regards,

Danny


Rob Caljouw:
Hi Danny,

I'm using Liferay 6.0.4 and setting the following:

auth.forward.by.last.path=false
auth.forward.by.redirect=false

worked for me as far as redirecting users to their private pages.

The problem I'm having is related to setting the virtual host. If the virtual host is set to localhost users are directed to their private page. When the virtual host is set to the domain name users are directed to <virtual-host-name>/home no matter what the auth.forward.* settings are.

If you, or anyone else, has any suggestions on how to direct users to their private page when the virtual host name is set I'd really appreciate hearing them.

Best regards.

RJC
Rob Caljouw
RE: redirect to the user's private page after login
October 10, 2010 9:31 AM
Answer

Rob Caljouw

Rank: New Member

Posts: 14

Join Date: June 3, 2009

Recent Posts

Hi Danny,

I couldn't find any combination of settings that would work so I wrote a login hook to handle it.

Best regards.

RJC
Danny Francisco
RE: redirect to the user's private page after login
October 11, 2010 6:29 AM
Answer

Danny Francisco

Rank: New Member

Posts: 10

Join Date: December 12, 2008

Recent Posts

Hi Rob,

That is great. I have thinking about hooks. But don't know much about it. How did you do it? Maybe you can you give me some pointers? or keywords I can google. is it hooks and events?
I'm playing with it right now. no luck yet.
:-)

Regards,

Danny


Rob Caljouw:
Hi Danny,

I couldn't find any combination of settings that would work so I wrote a login hook to handle it.

Best regards.

RJC
Rob Caljouw
RE: redirect to the user's private page after login
October 11, 2010 1:00 PM
Answer

Rob Caljouw

Rank: New Member

Posts: 14

Join Date: June 3, 2009

Recent Posts

Hi Danny,

the attached file contains the hook I created. It's pretty simplistic but it should get you started. It's a NetBeans project that includes everything you need and the dist folder contains a war file that should work.

If you have any questions please feel free to ask anytime.

Good luck.

RJC
Attachments: Login-hook.zip (1,102.1k)
Danny Francisco
RE: redirect to the user's private page after login
October 11, 2010 4:02 PM
Answer

Danny Francisco

Rank: New Member

Posts: 10

Join Date: December 12, 2008

Recent Posts

Hi Rob,

Thank you very much.

Best Regards,

Danny
Rob Caljouw
RE: redirect to the user's private page after login
October 11, 2010 7:28 PM
Answer

Rob Caljouw

Rank: New Member

Posts: 14

Join Date: June 3, 2009

Recent Posts

Hi Danny,

i hope it is of some help to you. if you have any questions please don't hesitate to ask.

Best regards.

RJC.
Tomas Guido
RE: redirect to the user's private page after login
November 24, 2010 10:01 AM
Answer

Tomas Guido

Rank: New Member

Posts: 3

Join Date: November 23, 2010

Recent Posts

Hi, i'm following this topic,
i write the code Shamsul write, but i need to add this as another file
in order of don't chage the core files

i read this can be posible, writing the new class name en el properties file like this

login.events.post=com.liferay.portal.events.LoginPostAction,com.liferay.portal.events.CustomLandingPageAction

but i don't know where to put the new file, i try tomcat lib, inside the webapps folder but can't make it work

any help is welcome

edit: i'm using a liferay tomcat bundle

thanks
---------------------------
Update: i read a howto, create my own hook to set my own version of the file.
Praveen P
RE: redirect to the user's private page after login
April 2, 2012 2:12 AM
Answer

Praveen P

Rank: Regular Member

Posts: 100

Join Date: February 20, 2012

Recent Posts

Hi Shamsul Bahrin
please let me know the path where i have to write this java code

Thanks
Dhrutika Vyas
RE: redirect to the user's private page after login
April 2, 2012 5:58 AM
Answer

Dhrutika Vyas

Rank: Expert

Posts: 438

Join Date: February 9, 2009

Recent Posts

Hi,

You need to write this code in your CustomDefaultLandingPageAction.

You need to overwrite below property in portal-ext.properties.

This call the class CustomDefaultLandingPageAction.java, which is used to redirect user after login
login.events.post=com.liferay.portal.events.CustomDefaultLandingPageAction

Regards,
Dhrutika
Tejas Kanani
RE: redirect to the user's private page after login
May 15, 2013 2:35 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

You can use Custom Landing Page Hook available in Liferay Marketplace for the same.
Including User's Private page it also provides other options to be redirected on after user logs in based on selected property value in portal.properties of hook.

1. userPrivatePage
2. userPublicPage
3. sitePublicPage
4. sitePrivatePage
5. organizationPublicPage
6. organizationPrivatePage

Thanks,
Tejas
Vipin Bardia
RE: redirect to the user's private page after login
July 9, 2015 3:32 AM
Answer

Vipin Bardia

Rank: Regular Member

Posts: 151

Join Date: February 27, 2011

Recent Posts

Hi Tejas,

I need a clarification.
How is it different to set last path in place of sendRedirect other than recommended way.
Or why it is a recommended way?

Regards.
Aristide Cittadino
RE: redirect to the user's private page after login
October 8, 2015 1:58 AM
Answer

Aristide Cittadino

Rank: New Member

Posts: 4

Join Date: October 16, 2013

Recent Posts

I use liferay 6.2 and the property default.landing.page.path=/user/${liferay:screenName}/home worked for me.
I have inserted the value from the control panel in Portal Settings but i think is the same from properties file
kunal hemrajani
RE: redirect to the user's private page after login
October 8, 2015 2:08 AM
Answer

kunal hemrajani

Rank: Regular Member

Posts: 109

Join Date: May 21, 2015

Recent Posts

Use custom landing Page hook.
Anuvab Ghosh
RE: redirect to the user's private page after login
July 18, 2016 4:03 AM
Answer

Anuvab Ghosh

Rank: Regular Member

Posts: 112

Join Date: April 17, 2015

Recent Posts

Aristide Cittadino:
I use liferay 6.2 and the property default.landing.page.path=/user/${liferay:screenName}/home worked for me.
I have inserted the value from the control panel in Portal Settings but i think is the same from properties file


Hi,

I have also do the same in my portal (Liferay 6.1). But it is not working and after logging url redirects to
http://localhost:8080/user/$%7Bliferay:screenName%7D/home


I think this is the problem character passing through browser url.

But how to solve it?

Please give some answer.

Thanks in advance.

Thanks and Regards,
Anuvab
Tejas Kanani
RE: redirect to the user's private page after login
July 18, 2016 7:45 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

Anuvab Ghosh:

I have also do the same in my portal (Liferay 6.1). But it is not working and after logging url redirects to
http://localhost:8080/user/$%7Bliferay:screenName%7D/home


Hi Anuvab,

As far as I know, ${liferay:screenName} token is only available starting from Liferay 6.2. So in Liferay 6.1 even if you specify it in property file it will not be replaced with the user's screen name and that's why you're seeing URL with '$%7Bliferay:screenName%7D' instead of user screen name.

You would either need to write your own custom landing page action OR you can also use Liferay Marketplace app - Custom Landing Page Hook.

Thanks,
Tejas
Anuvab Ghosh
RE: redirect to the user's private page after login
July 18, 2016 10:38 PM
Answer

Anuvab Ghosh

Rank: Regular Member

Posts: 112

Join Date: April 17, 2015

Recent Posts

Tejas Kanani:

...
As far as I know, ${liferay:screenName} token is only available starting from Liferay 6.2. So in Liferay 6.1 even if you specify it in property file it will not be replaced with the user's screen name and that's why you're seeing URL with '$%7Bliferay:screenName%7D' instead of user screen name.
...


Thanks Tejas for your reply. I know about the Custom Landing hook which is made by you, really this is a fantastic work. But unfortunately I am unable to setup properly with the Liferay portal.

Any more suggestions?

Thanks and Regards,
Anuvab
Tejas Kanani
RE: redirect to the user's private page after login
July 19, 2016 8:03 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

But unfortunately I am unable to setup properly with the Liferay portal.

Anuvab,
I'll be happy to help If you can share the issue/error you're facing with Custom Landing Page Hook on admin@opensourceforlife.com.

Thanks,
Tejas