Liferay If a user has already registered and he manually enters the URL of the login page?

I need that if the user is already logged in and he manually enters the login, he redirects to the home page ?. Please let me know how to do this.

thanks

+4
source share
2 answers

As I understand it, you want that even after logging in, if you enter the following login URL:

http://localhost:8080/web/guest/home?p_p_id=58&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&saveLastPath=0&_58_struts_action=%2Flogin%2Flogin 

then you must be delivered to the home page, that is, at http://localhost:8080/web/guest/home .

So, if that is the case, I think you can create a -filter hook servlet that intercepts all requests and checks the corresponding URL parameters, for example struts_action=/login/login , and does the following (in psuedo code):

 if(is_SignIn_URL) { // check if it is the sign-in URL if(isUserLoggedIn) { // check if user is logged-in // redirect to the home page configured in portal-ext.properties } else { // let the application work normally ie let it go to the sign-in page } } 

Also for information and in-depth understanding, you can check the lifeary AutoLoginFilter class (this is the actual servlet filter, but you can hook along the same lines) and liferay-web.xml for the URL c/portal/login , which will lead you to the home page, if the user is logged in or takes you to the login page.

And it does not depend on the use of cookies :-)

+1
source

You can write a redirection rule on your web server. The sample code below in the Apache httpd.conf file,

Create a cookie (say yourCookie ) as soon as you log in.

 RewriteEngine On RewriteCond %{HTTP:Cookie} yourCookie=([a-zA-Z0-9]+) RewriteCond %{REQUEST_URI} ^/web/portal/home/-/portal/login/ //This is your login page URL RewriteRule .* http://%{SERVER_NAME}/web/portal/home [R=302] //This is your Home Page URL 
0
source

All Articles