You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ra...@apache.org on 2012/04/20 15:45:27 UTC

svn commit: r1328374 - in /rave/trunk: rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/ rave-portal-resources/src/main/resources/ rave-portal-resources/src/main/webapp/WEB-INF/mailtemplates/

Author: raminder
Date: Fri Apr 20 13:45:27 2012
New Revision: 1328374

URL: http://svn.apache.org/viewvc?rev=1328374&view=rev
Log:
User account approval and notification to admin. RAVE-565 and RAVE-566

Added:
    rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/mailtemplates/admin_approval.ftl
Modified:
    rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
    rave/trunk/rave-portal-resources/src/main/resources/portal.properties

Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java?rev=1328374&r1=1328373&r2=1328374&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/service/impl/DefaultUserService.java Fri Apr 20 13:45:27 2012
@@ -83,12 +83,27 @@ public class DefaultUserService implemen
     @Value("${portal.mail.service.baseurl}")
     private String baseUrl;
 
+    @Value("${protal.user.account.admin.subject}")
+    private String userAccountApprovalSubject;
+
+    @Value("${protal.user.account.admin.template}")
+    private String userAccountApprovalTemplate;
+
+    @Value("${protal.user.account.needapporval}")
+    private boolean userAccountApproval;
+
+    @Value("${protal.user.account.admin.email}")
+    private String approvalAdminEmail;
+
+    @Value("${portal.mail.service.loginpage}")
+    private String loginUrl;
+
     @Autowired
     public DefaultUserService(PageRepository pageRepository,
                               UserRepository userRepository,
                               WidgetRatingRepository widgetRatingRepository,
                               WidgetCommentRepository widgetCommentRepository,
-                              WidgetRepository widgetRepository, 
+                              WidgetRepository widgetRepository,
                               PageTemplateRepository pageTemplateRepository) {
         this.userRepository = userRepository;
         this.pageRepository = pageRepository;
@@ -160,8 +175,17 @@ public class DefaultUserService implemen
     @Override
     @Transactional
     public void registerNewUser(User user) {
+    	if(userAccountApproval){
+    		user.setEnabled(false);
+    	}
         User managedUser = userRepository.save(user);
         pageRepository.createPageForUser(managedUser, pageTemplateRepository.getDefaultPage(PageType.PERSON_PROFILE));
+        if(userAccountApproval && !approvalAdminEmail.isEmpty()){
+            Map<String, Object> templateData = new HashMap<String, Object>();
+            templateData.put("user", user);
+            templateData.put("portalUrl", loginUrl);
+        	emailService.sendEmail(approvalAdminEmail, userAccountApprovalSubject, userAccountApprovalTemplate, templateData);
+    	}
     }
 
     @Override

Modified: rave/trunk/rave-portal-resources/src/main/resources/portal.properties
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/resources/portal.properties?rev=1328374&r1=1328373&r2=1328374&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/resources/portal.properties (original)
+++ rave/trunk/rave-portal-resources/src/main/resources/portal.properties Fri Apr 20 13:45:27 2012
@@ -18,7 +18,7 @@
 #
 
 #
-# These properties are used to construct the opensocial engine's URL. See 
+# These properties are used to construct the opensocial engine's URL. See
 # for example page.jsp. Changing them does not change the actual path configuration
 # of shindig.
 #
@@ -72,4 +72,11 @@ portal.mail.username.template=username_r
 portal.mail.passwordservice.subject=Rave password reminder service
 portal.mail.passwordservice.template=password_reminder.ftl
 portal.mail.passwordservice.valid.minutes=30
-portal.mail.service.baseurl=http://localhost:8080/portal/app/changepassword/
\ No newline at end of file
+portal.mail.service.baseurl=http://localhost:8080/portal/app/changepassword/
+
+# Account approval
+protal.user.account.needapporval=false
+protal.user.account.admin.email=
+protal.user.account.admin.subject=Rave User Approval
+protal.user.account.admin.template=admin_approval.ftl
+portal.mail.service.loginpage=http://localhost:8080/portal/
\ No newline at end of file

Added: rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/mailtemplates/admin_approval.ftl
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/mailtemplates/admin_approval.ftl?rev=1328374&view=auto
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/mailtemplates/admin_approval.ftl (added)
+++ rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/mailtemplates/admin_approval.ftl Fri Apr 20 13:45:27 2012
@@ -0,0 +1,31 @@
+<#--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+<#-- @ftlvariable name="user" type="org.apache.rave.portal.model.User" -->
+<#-- @ftlvariable name="reminderUrl" type="java.lang.String" -->
+Dear Admin,
+
+We've received a request to approve Rave account for ${user.getUsername()}.
+
+To complete this process, open the following link in your browser:
+
+${portalUrl}
+
+User status is not enabled until a action is taken.
+
+