Forums de discussion

redirect to the user's private page after login

thumbnail
jacky hung, modifié il y a 15 années.

redirect to the user's private page after login

New Member Publications: 8 Date d'inscription: 08/04/08 Publications récentes
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, modifié il y a 15 années.

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

Liferay Master Publications: 546 Date d'inscription: 08/08/07 Publications récentes
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, modifié il y a 15 années.

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

Junior Member Publications: 43 Date d'inscription: 27/08/07 Publications récentes
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, modifié il y a 15 années.

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

New Member Envoyer: 1 Date d'inscription: 16/03/09 Publications récentes
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, modifié il y a 13 années.

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

Junior Member Publications: 52 Date d'inscription: 01/08/09 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 10 Date d'inscription: 12/12/08 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 14 Date d'inscription: 03/06/09 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 10 Date d'inscription: 12/12/08 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 14 Date d'inscription: 03/06/09 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 10 Date d'inscription: 12/12/08 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 14 Date d'inscription: 03/06/09 Publications récentes
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

Pièces jointes:

thumbnail
Danny Francisco, modifié il y a 13 années.

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

New Member Publications: 10 Date d'inscription: 12/12/08 Publications récentes
Hi Rob,

Thank you very much.

Best Regards,

Danny
thumbnail
Rob Caljouw, modifié il y a 13 années.

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

New Member Publications: 14 Date d'inscription: 03/06/09 Publications récentes
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, modifié il y a 13 années.

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

Junior Member Publications: 52 Date d'inscription: 01/08/09 Publications récentes
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, modifié il y a 13 années.

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

New Member Publications: 3 Date d'inscription: 23/11/10 Publications récentes
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, modifié il y a 12 années.

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

Regular Member Publications: 100 Date d'inscription: 21/02/12 Publications récentes
Hi Shamsul Bahrin
please let me know the path where i have to write this java code

Thanks
thumbnail
Dhrutika Parekh, modifié il y a 12 années.

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

Expert Publications: 435 Date d'inscription: 09/02/09 Publications récentes
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, modifié il y a 10 années.

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

Liferay Master Publications: 654 Date d'inscription: 06/01/09 Publications récentes
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, modifié il y a 8 années.

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

Regular Member Publications: 162 Date d'inscription: 28/02/11 Publications récentes
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, modifié il y a 8 années.

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

New Member Publications: 5 Date d'inscription: 16/10/13 Publications récentes
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, modifié il y a 8 années.

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

Regular Member Publications: 109 Date d'inscription: 21/05/15 Publications récentes
Use custom landing Page hook.
thumbnail
Anuvab Ghosh, modifié il y a 7 années.

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

Regular Member Publications: 130 Date d'inscription: 18/04/15 Publications récentes
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, modifié il y a 7 années.

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

Liferay Master Publications: 654 Date d'inscription: 06/01/09 Publications récentes
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, modifié il y a 7 années.

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

Regular Member Publications: 130 Date d'inscription: 18/04/15 Publications récentes
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, modifié il y a 7 années.

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

Liferay Master Publications: 654 Date d'inscription: 06/01/09 Publications récentes
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, modifié il y a 6 années.

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

New Member Publications: 19 Date d'inscription: 12/04/17 Publications récentes
Thank You emoticonAristide Cittadino
it is working in liferay 7