留言板
User deleting his own account IllegalStateException
Kim A Kunc,修改在13 年前。
User deleting his own account IllegalStateException
Junior Member 帖子: 37 加入日期: 09-2-18 最近的帖子
My project requires users being able to delete their own accounts.
I created a portlet that deactivates the user and then deletes the user account.
I then want to invalidate his session and redirect him to the portal's main path.
This is what I do:
However I end up with a blank page and an IllegalStateException:
javax.portlet.PortletException: Request processing failed...
Caused by: java.lang.IllegalStateException: setAttribute: Session already invalidated
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1321)
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1286)
Any suggestions are much appreciated !
I'm using the CE Edition 6.0.5 with Tomcat bundle.
I created a portlet that deactivates the user and then deletes the user account.
I then want to invalidate his session and redirect him to the portal's main path.
This is what I do:
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
String redirect = themeDisplay.getPathMain();
UserLocalServiceUtil.updateActive(currentUser.getUserId(), false);
try {
UserLocalServiceUtil.deleteUser(currentUser);
HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(request);
HttpSession session = servletRequest.getSession();
session.invalidate();
} catch (Exception e) {
//
}
response.sendRedirect(redirect);
However I end up with a blank page and an IllegalStateException:
javax.portlet.PortletException: Request processing failed...
Caused by: java.lang.IllegalStateException: setAttribute: Session already invalidated
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1321)
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1286)
Any suggestions are much appreciated !
I'm using the CE Edition 6.0.5 with Tomcat bundle.
jelmer kuperus,修改在13 年前。
RE: User deleting his own account IllegalStateException
Liferay Legend 帖子: 1191 加入日期: 10-3-10 最近的帖子
1. You should delete the user with UserLocalServiceUtil.deleteUser(long userId) instead of with UserLocalServiceUtil.deleteUser(User user)
for some reason the liferay devs chose to override the method that takes a long to remove the user from the search index, delete a user's groep etc but they didn't do this for the method that accepts the group object
2. try redirecting to themeDisplay.getURLSignOut() instead of doing your session voodoo.
for some reason the liferay devs chose to override the method that takes a long to remove the user from the search index, delete a user's groep etc but they didn't do this for the method that accepts the group object
2. try redirecting to themeDisplay.getURLSignOut() instead of doing your session voodoo.
Kim A Kunc,修改在13 年前。
RE: User deleting his own account IllegalStateException
Junior Member 帖子: 37 加入日期: 09-2-18 最近的帖子
Hi Jelmer, thanks for your reply!
My user is now properly deleted. Works fine, thanks!
Problem now is the redirect. I've tried different approaches
forwarding to /c/portal/logout or to a jsp page that will then forward to somewhere else.
I had a look at com.liferay.portal.action.LogoutAction that should be called when I redirect to /c/portal/logout
but apparently the action is not processed. The user is never logged out correctly and I end up with a blank page ( no errors in the log)
btw, the same thing happens if the admin deletes a user in the control panel that still has a running session.
My user is now properly deleted. Works fine, thanks!
Problem now is the redirect. I've tried different approaches
forwarding to /c/portal/logout or to a jsp page that will then forward to somewhere else.
I had a look at com.liferay.portal.action.LogoutAction that should be called when I redirect to /c/portal/logout
but apparently the action is not processed. The user is never logged out correctly and I end up with a blank page ( no errors in the log)
btw, the same thing happens if the admin deletes a user in the control panel that still has a running session.
Bharanidharan Viswanathan,修改在12 年前。
RE: User deleting his own account IllegalStateException
New Member 帖子: 5 加入日期: 09-10-8 最近的帖子
Are you able to do this now ?