Forums de discussion

Redirect guest user to the current page after login

Traolly Xiong, modifié il y a 9 années.

Redirect guest user to the current page after login

Regular Member Publications: 195 Date d'inscription: 30/12/11 Publications récentes
Hello ,
I'm trying to redirect the guest user back to the current page after login via the "login.jsp" hook. Is that the best approach or there
a better approach?

Any direction is much appreciated.

Thanks.
thumbnail
Pankaj Kathiriya, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

Liferay Master Publications: 722 Date d'inscription: 05/08/10 Publications récentes
Isnt this a default behaviour that user gets redirected to last visited page after login? Which liferay version are you using?
thumbnail
Suraj Bihari, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

Junior Member Publications: 44 Date d'inscription: 20/12/13 Publications récentes
Hello Traolly,
There is a way to redirect the signed in user to the previous page:
https://www.liferay.com/community/forums/-/message_boards/message/8264376

HTH,
Suraj
Traolly Xiong, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

Regular Member Publications: 195 Date d'inscription: 30/12/11 Publications récentes
I will try this out.... But in a nutshell what I am trying to accomplish is:

1) Hit a webapp URL (i.e. "/<plugin web app>/xyz")
2) Redirect to a secured page
3) Trigger login
4) After login, I want to redirect back to the #1) URL.

I've tried to create session variable of the URL, but some reason it loses it's value through the login process.

Any tips / tricks on how I can possibly accomplish this?

My workaround was, first hit a secure page, trigger some javascript and then redirect to #1) web app URL, and then redirect to #2) URL.

Thanks.
thumbnail
Suraj Bihari, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

Junior Member Publications: 44 Date d'inscription: 20/12/13 Publications récentes
By default if you try to access a private page /group/secure-page , you will get redirected to a login page /web/home. After successful login you'll be redirected back to the private page /group/secure-page.

So creating a post login event (hook) will be sufficient.

HTH!
Suraj
Vishal M, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

New Member Publications: 14 Date d'inscription: 15/07/14 Publications récentes
This may help you

Create a theme and change portal_normal.vm
1)Check for logged in user using
#if ($is_signed_in)
-----------------------
------------------------
#else
show sign in portlet (portlet id 58)
#end
2) Apply this theme to your page.
Traolly Xiong, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

Regular Member Publications: 195 Date d'inscription: 30/12/11 Publications récentes
Very interesting solutions. I've decided to secure a page and let it log in, and use js to redirect the user for my use case.
I'll definitely try the solutions mentioned if the use case is universal and / or make sense to.

Many thanks.
thumbnail
Suraj Bihari, modifié il y a 9 années.

RE: Redirect guest user to the current page after login

Junior Member Publications: 44 Date d'inscription: 20/12/13 Publications récentes
Enjoy Liferay!