Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay Portal 7.2 GA2 - Redirect user to Site
Hi,
on Liferay Portal 7.2, I should redirect to my home site after logging in. Is there a way? i tried with the landing page but as they are filtered as only $ screenname and $ userid.
In practice I should redirect certain people on one site and others on another site
Thank you all
on Liferay Portal 7.2, I should redirect to my home site after logging in. Is there a way? i tried with the landing page but as they are filtered as only $ screenname and $ userid.
In practice I should redirect certain people on one site and others on another site
Thank you all
We usually add our own post login action to do that.
I cut a bit of sample code out of one of our modules to give you an idea how it would look like. If the logic isn't too complicated, it should be easy enough to implement.
@Component(
immediate = true, property = {"key=login.events.post"},
service = LifecycleAction.class
)
public class MyRedirectAction implements LifecycleAction {
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
User user = null;
try {
user = PortalUtil.getUser(lifecycleEvent.getRequest());
} catch (PortalException e) {
throw new ActionException(e);
}
String redirectURL = getRedirectURL(user);
if (redirectURL != null) {
try {
lifecycleEvent.getResponse().sendRedirect(redirectURL);
} catch (IOException e) {
throw new ActionException(e);
}
}
}
}
I cut a bit of sample code out of one of our modules to give you an idea how it would look like. If the logic isn't too complicated, it should be easy enough to implement.
@Component(
immediate = true, property = {"key=login.events.post"},
service = LifecycleAction.class
)
public class MyRedirectAction implements LifecycleAction {
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
User user = null;
try {
user = PortalUtil.getUser(lifecycleEvent.getRequest());
} catch (PortalException e) {
throw new ActionException(e);
}
String redirectURL = getRedirectURL(user);
if (redirectURL != null) {
try {
lifecycleEvent.getResponse().sendRedirect(redirectURL);
} catch (IOException e) {
throw new ActionException(e);
}
}
}
}
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™