Author: jkoster
Date: 2009-06-05 11:42:18 +0200 (Fri, 05 Jun 2009)
New Revision: 35749

Modified:
   
CMSContainer/branches/b1_6/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/RegisterPortlet.java
Log:
CMSC-1357 - Newsletter: create newsletter-registration portlet; missing code 
from b1_5

Modified: 
CMSContainer/branches/b1_6/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/RegisterPortlet.java
===================================================================
--- 
CMSContainer/branches/b1_6/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/RegisterPortlet.java
    2009-06-05 09:37:12 UTC (rev 35748)
+++ 
CMSContainer/branches/b1_6/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/RegisterPortlet.java
    2009-06-05 09:42:18 UTC (rev 35749)
@@ -113,6 +113,8 @@
          Long authenticationId = 
authenticationService.getAuthenticationIdForUserId(emailTo);
    
          if (authenticationId == null) {
+            // TODO check if password is mandatory
+            //if (passwordText == null) passwordText="";
             Authentication authentication = 
authenticationService.createAuthentication(emailTo, passwordText);
             if (authentication.getId() != null) {
                authId = authentication.getId();
@@ -151,7 +153,7 @@
                   errorMessages.put(ACEGI_SECURITY_DEFAULT, "Sending email 
failed, from '" + emailFrom + "' to '" + emailTo + "'!");
                }
                if (errorMessages.isEmpty()) {
-                  response.setRenderParameter("email", emailTo);
+                  response.setRenderParameter(ACEGI_SECURITY_FORM_EMAIL_KEY, 
emailTo);
                } else {
                   //Email could not be sent, but the user is created..should 
remove user & authentication
                   
personHibernateService.deletePersonByAuthenticationId(authId);
@@ -163,9 +165,15 @@
                errorMessages.put(ACEGI_SECURITY_DEFAULT, "adding of 
authenticationId in database failed");
             }
          } else {
-            errorMessages.put(ACEGI_SECURITY_DEFAULT, "register.user.exists");
-         }
+            if (!isExistingUserAllowed()) {
+               errorMessages.put(ACEGI_SECURITY_DEFAULT, 
"register.user.exists");
+            } else {
+               authId = authenticationId;
+               response.setRenderParameter("active", "subscribed");
+               request.getPortletSession().setAttribute("active", 
"subscribed");
+            }
       }
+      }
 
       if (errorMessages.size() > 0) {
          request.getPortletSession().setAttribute(ERRORMESSAGES, 
errorMessages);
@@ -275,5 +283,12 @@
        throw new IllegalArgumentException("Unknown key: " + key);
    }
    
+   /* 
+    * For newsletter registration it is okay to have an existing user
+    * for ordinary registration it is not okay.
+    */
+   protected boolean isExistingUserAllowed() {
+       return false;
+   }
    
 }

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to