I need that if a user is already login and he manually enters login path he redirects to home page?.Please let me know how to how to perform this.
Thanks
I need that if a user is already login and he manually enters login path he redirects to home page?.Please let me know how to how to perform this.
Thanks
As far as I understand you want that even after login if you enter the following sign-in 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 should be taken to the home page i.e. to http://localhost:8080/web/guest/home
.
So if this is the case then I think you can create a servlet-filter hook which would intercept all requests and check for the relevant parameters of the URL such as struts_action=/login/login
and do 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 i.e. let it go to the sign-in page
}
}
Also for information and in-depth understand you can check lifeary's AutoLoginFilter
class (this is an actual Servlet-filter but you can make a hook along the same lines) and liferay-web.xml
for the URL c/portal/login
which takes you to the home
page if the User is logged-in or else takes you to the sign-in page.
And this is independent of using a Cookie :-)
You can write a Redirection rule in your web server. Example code below in Apache httpd.conf file,
Create a Cookie (lets say yourCookie
) as soon as you login.
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