Fórumok

Redirect to previous page after login

gary b, módosítva 9 év-val korábban

Redirect to previous page after login

Junior Member Bejegyzések: 81 Csatlakozás dátuma: 2013.02.02. Legújabb bejegyzések
Liferay 6.1.0.

We are giving direct links to users in mail for accessing some internal pages. When user click on those pages he first needs to login.
Previously every time after login user is landing to default home page.

I have done below changes in my classic theme portal-normal.vm:


#set ($urlEncoder = $portal.getClass().forName("java.net.URLEncoder")) ##static class
#set ($currentPage = "$themeDisplay.getURLPortal()$themeDisplay.getURLCurrent()" )
#set ($myRedirect = $urlEncoder.encode("$currentPage", "UTF-8"))
<a href="$sign_in_url&amp;redirect=$myRedirect" id="sign-in" rel="nofollow">$sign_in_text</a>

After this when i click on url in mail it append redirect url with sign-in url.

But the issue is, for some pages it is working fine but for some pages it is redirecting to default landing page an not appending the previous url.
Richard Fincher, módosítva 9 év-val korábban

RE: Redirect to previous page after login

New Member Bejegyzések: 3 Csatlakozás dátuma: 2014.03.07. Legújabb bejegyzések
I have a similar problem and discovered that if the user makes a typo and the sign in fails, the user gets sent to the error page to try to sign in again. This page redirects to the default page when the user successfully signs in, rather than the target page in the first sign in page.

I haven't figured out a work around for this yet.


Rick
thumbnail
Andew Jardine, módosítva 9 év-val korábban

RE: Redirect to previous page after login

Liferay Legend Bejegyzések: 2416 Csatlakozás dátuma: 2010.12.22. Legújabb bejegyzések
Hey Gary,

I think I did something like this in the past (with Login) and used the saveLastPath parameter with a value of 1 when I wanted it to be retained, and a value of 0 when I did not. If memory serves, this only works if you have forward.by.last.path=true (which in 6.2 is the default in the portal.properties file).

Give that a shot and let me know if it helps. If it does not, then I'll see if I can dig up the source. It was a while back.