Search code examples
liferayliferay-6

In liferay, how do I redirect to the login page and back?


In my doView mehtod, under certain conditions (based on the url parameters), I would like to require that the user login before continuing.

I am basically trying to reproduce the behaviour of guest trying to access a private page: the user is redirected to the login page, then back to the original page after login.

What code should I put in my doView method to reproduce this ?

Thanks and Best regards, Alain

PS. I am using liferay 6.1 GA3


Solution

  • You can redirect user to url like /c/portal/login?redirect=currenturl.

    Here, currenturl will be URL where you want to come back.