留言板

redirect to the user's private page after login

thumbnail
jacky hung,修改在15 年前。

redirect to the user's private page after login

New Member 帖子: 8 加入日期: 08-4-8 最近的帖子
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
thumbnail
Tobias Amon,修改在15 年前。

RE: redirect to the user's private page after login

Liferay Master 帖子: 546 加入日期: 07-8-8 最近的帖子
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


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


that's it.

kind regards
Tobias
thumbnail
Mario Muñoz,修改在15 年前。

RE: redirect to the user's private page after login

Junior Member 帖子: 43 加入日期: 07-8-27 最近的帖子
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:


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


Hope this helps.

Mario.
thumbnail
Shamsul Bahrin,修改在15 年前。

RE: redirect to the user's private page after login

New Member 发布: 1 加入日期: 09-3-16 最近的帖子
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.....
thumbnail
Ali Shahrami,修改在13 年前。

RE: redirect to the user's private page after login

Junior Member 帖子: 52 加入日期: 09-8-1 最近的帖子
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
thumbnail
Danny Francisco,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 10 加入日期: 08-12-12 最近的帖子
Hi Ali,

I tried your solution with 6.0.4. Still not redirecting to private page. What version of Liferay are you using ?
thumbnail
Rob Caljouw,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 14 加入日期: 09-6-3 最近的帖子
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
thumbnail
Danny Francisco,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 10 加入日期: 08-12-12 最近的帖子
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
thumbnail
Rob Caljouw,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 14 加入日期: 09-6-3 最近的帖子
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
thumbnail
Danny Francisco,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 10 加入日期: 08-12-12 最近的帖子
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
thumbnail
Rob Caljouw,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 14 加入日期: 09-6-3 最近的帖子
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
thumbnail
Danny Francisco,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 10 加入日期: 08-12-12 最近的帖子
Hi Rob,

Thank you very much.

Best Regards,

Danny
thumbnail
Rob Caljouw,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 14 加入日期: 09-6-3 最近的帖子
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.
thumbnail
Ali Shahrami,修改在13 年前。

RE: redirect to the user's private page after login

Junior Member 帖子: 52 加入日期: 09-8-1 最近的帖子
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
Tomas Guido,修改在13 年前。

RE: redirect to the user's private page after login

New Member 帖子: 3 加入日期: 10-11-23 最近的帖子
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.
thumbnail
devaraj S,修改在12 年前。

RE: redirect to the user's private page after login

Regular Member 帖子: 100 加入日期: 12-2-21 最近的帖子
Hi Shamsul Bahrin
please let me know the path where i have to write this java code

Thanks
thumbnail
Dhrutika Parekh,修改在12 年前。

RE: redirect to the user's private page after login

Expert 帖子: 435 加入日期: 09-2-9 最近的帖子
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
thumbnail
Tejas Kanani,修改在10 年前。

RE: redirect to the user's private page after login

Liferay Master 帖子: 654 加入日期: 09-1-6 最近的帖子
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
thumbnail
Vipin Bardia,修改在8 年前。

RE: redirect to the user's private page after login

Regular Member 帖子: 162 加入日期: 11-2-28 最近的帖子
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.
thumbnail
Aristide Cittadino,修改在8 年前。

RE: redirect to the user's private page after login

New Member 帖子: 5 加入日期: 13-10-16 最近的帖子
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,修改在8 年前。

RE: redirect to the user's private page after login

Regular Member 帖子: 109 加入日期: 15-5-21 最近的帖子
Use custom landing Page hook.
thumbnail
Anuvab Ghosh,修改在7 年前。

RE: redirect to the user's private page after login

Regular Member 帖子: 130 加入日期: 15-4-18 最近的帖子
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
thumbnail
Tejas Kanani,修改在7 年前。

RE: redirect to the user's private page after login

Liferay Master 帖子: 654 加入日期: 09-1-6 最近的帖子
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
thumbnail
Anuvab Ghosh,修改在7 年前。

RE: redirect to the user's private page after login

Regular Member 帖子: 130 加入日期: 15-4-18 最近的帖子
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
thumbnail
Tejas Kanani,修改在7 年前。

RE: redirect to the user's private page after login

Liferay Master 帖子: 654 加入日期: 09-1-6 最近的帖子
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
santhosh kumar,修改在6 年前。

RE: redirect to the user's private page after login

New Member 帖子: 19 加入日期: 17-4-12 最近的帖子
Thank You emoticonAristide Cittadino
it is working in liferay 7