Author: thomas.heute(a)jboss.com
Date: 2010-12-09 07:24:59 -0500 (Thu, 09 Dec 2010)
New Revision: 5523
Modified:
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
Log:
JBEPP-565: Captcha doesn't change after successful registration.
Now it should update all the time
Modified:
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java 2010-12-09
10:04:35 UTC (rev 5522)
+++
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/RegisterPortletApplicationController.java 2010-12-09
12:24:59 UTC (rev 5523)
@@ -67,18 +67,18 @@
{
PortletSession session = req.getPortletSession();
Captcha captcha;
- if (session.getAttribute(NAME, PortletSession.APPLICATION_SCOPE) == null)
+ if (session.getAttribute(NAME) == null)
{
captcha = new Captcha.Builder(_width,
_height).addText().gimp().addNoise().addBackground().build();
- session.setAttribute(NAME, captcha, PortletSession.APPLICATION_SCOPE);
+ session.setAttribute(NAME, captcha);
writeImage(resp, captcha.getImage());
return;
}
- captcha = (Captcha)session.getAttribute(NAME, PortletSession.APPLICATION_SCOPE);
+ captcha = (Captcha)session.getAttribute(NAME);
writeImage(resp, captcha.getImage());
}
Modified:
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2010-12-09
10:04:35 UTC (rev 5522)
+++
epp/portal/branches/EPP_5_1_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2010-12-09
12:24:59 UTC (rev 5523)
@@ -19,7 +19,6 @@
package org.exoplatform.account.webui.component;
-import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.CaptchaValidator;
import org.exoplatform.portal.webui.UICaptcha;
import org.exoplatform.portal.webui.util.Util;
@@ -27,6 +26,7 @@
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIApplication;
@@ -99,10 +99,11 @@
if(popupMessages.getWarnings().size() > 0 || popupMessages.getErrors().size()
> 0)
{
//Invalidate the capcha
- PortalRequestContext prContext = Util.getPortalRequestContext();
- HttpServletRequest request = prContext.getRequest();
- HttpSession session = request.getSession();
- session.removeAttribute(Captcha.NAME);
+ if (context instanceof PortletRequestContext)
+ {
+ PortletRequestContext prc = (PortletRequestContext)context;
+ prc.getRequest().getPortletSession().removeAttribute(Captcha.NAME);
+ }
context.addUIComponentToUpdateByAjax(getChild(UIRegisterInputSet.class));
}
}
@@ -112,9 +113,6 @@
@Override
public void execute(Event<UIRegisterForm> event) throws Exception
{
- // Invalidate the captcha image
- PortalRequestContext prContext = Util.getPortalRequestContext();
-
UIRegisterForm registerForm = event.getSource();
OrganizationService orgService =
registerForm.getApplicationComponent(OrganizationService.class);
UserHandler userHandler = orgService.getUserHandler();
@@ -127,9 +125,13 @@
UIApplication uiApp = context.getUIApplication();
uiApp.addMessage(new
ApplicationMessage("UIRegisterForm.registerWithSuccess.message", null));
}
- HttpServletRequest request = prContext.getRequest();
- HttpSession session = request.getSession();
- session.removeAttribute(Captcha.NAME);
+
+ //Invalidate the capcha
+ if (context instanceof PortletRequestContext)
+ {
+ PortletRequestContext prc = (PortletRequestContext)context;
+ prc.getRequest().getPortletSession().removeAttribute(Captcha.NAME);
+ }
}
}
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java 2010-12-09
10:04:35 UTC (rev 5522)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java 2010-12-09
12:24:59 UTC (rev 5523)
@@ -49,7 +49,7 @@
PortletRequest req = ctx.getRequest();
PortletSession session = req.getPortletSession();
- Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME,
PortletSession.APPLICATION_SCOPE);
+ Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
if ((captcha != null) && (captcha.isCorrect((String) uiInput.getValue())))
{
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2010-12-09
10:04:35 UTC (rev 5522)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2010-12-09
12:24:59 UTC (rev 5523)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.exoplatform.portal.webui;
+import java.util.Calendar;
+
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.form.UIFormStringInput;
@@ -50,9 +52,9 @@
// context.getPortalContextPath() + "/captcha?v=" +
Calendar.getInstance().getTimeInMillis()
+ String random = "&v=" + Calendar.getInstance().getTimeInMillis();
-
- context.getWriter().write("<div id='" + getId() +
"'><img src=\"" + url.toString() + "\"
/><br/>");
+ context.getWriter().write("<div id='" + getId() +
"'><img src=\"" + url.toString() + random + "\"
/><br/>");
super.processRender(context);
context.getWriter().write("</div>");
}
Show replies by date