掲示板

different Default landing page path based on users

8年前 に Sagar P によって更新されました。

different Default landing page path based on users

Junior Member 投稿: 34 参加年月日: 14/09/04 最新の投稿
Hi all,

can we achive different landing page path for different user after he logs out.
we are using liferay 6.1.2 CE

i.e when admin logs out..landing page is /web/guest/welcome and when any other user other than admin, logs out landing page is /web/guest/home.
We want get first who the user is,
if he is admin
set DEFAULT_LOGOUT_PAGE_PATH= /web/guest/welcome
else
DEFAULT_LOGOUT_PAGE_PATH=/web/guest/home.

How we verify who the user is and according to that wher to change the path(do we need to override any class)

How can we achive this?
we have only one community.
please any body advice.
thumbnail
8年前 に Jeffrey Paul Handa によって更新されました。

RE: different Default landing page path based on users

Liferay Master 投稿: 541 参加年月日: 08/12/01 最新の投稿
Hi Sagar,

You'll need to implement your logic with some custom code that you would hook into the log-out process. Liferay provides several properties that can modify the log-in and log-out behavior of the portal:

https://github.com/liferay/liferay-portal/blob/6.2.x/portal-impl/src/portal.properties#L4462-L4473

If you scroll up a little bit in that file, to the top of the Portal Events section, you'll see a comment that explains how to extend these events.

The preferred way to extend Portal Events (and deploy your code) would be to use a Hook. The Liferay Developer Network has a tutorial on Performing a Custom Action Using a Hook that should also provide some useful information.
8年前 に Sagar P によって更新されました。

RE: different Default landing page path based on users

Junior Member 投稿: 34 参加年月日: 14/09/04 最新の投稿
Hi jeffrey,
Thanks for the reply.

I am bit confused regarding which event to use i.e login pre or post action.

Because DefualtLogoutPageAction class(where it takes DEFAULT_LOGOUT_PAGE_PATH) falls in logout.post.event property as mentioned in portal.properties file.

As i am changing defualt logout landing page based on the user ,i dont think so i can use post event because in post event we cannot get the user detail or who is the user(correct me if am wrong).

else

If we choose pre event, in that i know how to get whether the user is admin or not,but i dont know how to change the defualt logout landing path.
please help out.
Do i need to change anything in DefualtLogoutPageAction class.
probably with some code example would help a lot(regarding how to change the path).

Thanks
thumbnail
8年前 に Jitendra Rajput によって更新されました。

RE: different Default landing page path based on users

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
You can create event hook and create post logout even hook by overriding logout.events.post property.

In your custom post logout class you can check whether user is admin or not. You can get current logged in user using
PortalUtil.getUser(request)
.

Once you know where to redirect you can simply set logout path like

request.setAttribute(WebKeys.REFERER, path);


You can also redirect by doing response.sendRedirect(urlToredirect)

Thank you ,
Jitendra
8年前 に Sagar P によって更新されました。

RE: different Default landing page path based on users

Junior Member 投稿: 34 参加年月日: 14/09/04 最新の投稿
Thanks Jitendra for the reply.
I followed the steps as u mentioned.
Now it is working as expected.emoticon