usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [1/2] usergrid git commit: Fix reactivateTest and handle re-activation differently from auto-activation with confirmation requirements.
Date Wed, 07 Sep 2016 03:38:48 GMT
Repository: usergrid
Updated Branches:
  refs/heads/master d090154e7 -> efb5bfbfd


Fix reactivateTest and handle re-activation differently from auto-activation with confirmation
requirements.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/b5670149
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/b5670149
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/b5670149

Branch: refs/heads/master
Commit: b56701499ae9531b6524b7742f45532f727af2ef
Parents: 1894d61
Author: Michael Russo <mrusso@apigee.com>
Authored: Tue Sep 6 20:36:52 2016 -0700
Committer: Michael Russo <mrusso@apigee.com>
Committed: Tue Sep 6 20:36:52 2016 -0700

----------------------------------------------------------------------
 .../usergrid/rest/management/users/UserResource.java   |  2 +-
 .../apache/usergrid/rest/management/AdminUsersIT.java  |  2 +-
 .../apache/usergrid/management/ManagementService.java  |  2 +-
 .../management/cassandra/ManagementServiceImpl.java    | 13 ++++++++-----
 4 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5670149/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
index af37cf5..066f734 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
@@ -433,7 +433,7 @@ public class UserResource extends AbstractContextResource {
 
         ApiResponse response = createApiResponse();
 
-        management.startAdminUserActivationFlow( null, user );
+        management.startAdminUserActivationFlow( null, user, true);
 
         response.setAction( "reactivate user" );
         return response;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5670149/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index 3adc719..a8bd834 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -534,7 +534,7 @@ public class AdminUsersIT extends AbstractRestIT {
     @Test
     public void reactivateTest() throws Exception {
         //call reactivate endpoint on default user
-        clientSetup.getRestClient().management().users().user( clientSetup.getUsername()
).reactivate();
+        clientSetup.getRestClient().management().users().user( clientSetup.getUsername()
).reactivate().get();
         refreshIndex();
 
         //Create mocked inbox and check to see if you recieved an email in the users inbox.

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5670149/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
index 5ac1713..2b88b07 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
@@ -247,7 +247,7 @@ public interface ManagementService {
 
 	void removeOrganizationApplication( UUID organizationId, UUID applicationId ) throws Exception;
 
-	void startAdminUserActivationFlow( UUID organizationId, UserInfo user ) throws Exception;
+	void startAdminUserActivationFlow(UUID organizationId, UserInfo user, boolean fromReactivate)
throws Exception;
 
 	void sendAdminUserEmail( UserInfo user, String subject, String html ) throws Exception;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b5670149/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 84b573b..98cfedf 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -921,7 +921,7 @@ public class ManagementServiceImpl implements ManagementService {
         if (    !user.getEmail().equals( properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL
) )
              && !user.getEmail().equals( properties .getProperty( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL
) ) ) {
             if(!tokens.isExternalSSOProviderEnabled()) {
-                this.startAdminUserActivationFlow(organizationId, userInfo);
+                this.startAdminUserActivationFlow(organizationId, userInfo, false);
             }
         }
 
@@ -2556,9 +2556,14 @@ public class ManagementServiceImpl implements ManagementService {
 
 
     @Override
-    public void startAdminUserActivationFlow( UUID organizationId, UserInfo user ) throws
Exception {
+    public void startAdminUserActivationFlow(UUID organizationId, UserInfo user,
+                                             boolean fromReactivate) throws Exception {
+        // re-activation flow ( or auto-activated flow )
         if ( user.isActivated() ) {
-            sendAdminUserConfirmationEmail( organizationId, user );
+            // send email always if from re-activation, otherwise check the property flag
+            if ( fromReactivate || newAdminUsersRequireConfirmation() ) {
+                sendAdminUserConfirmationEmail(organizationId, user);
+            }
             sendAdminUserActivatedEmail( user );
             sendSysAdminNewAdminActivatedNotificationEmail( organizationId, user );
         }
@@ -2647,7 +2652,6 @@ public class ManagementServiceImpl implements ManagementService {
 
 
     public void sendAdminUserConfirmationEmail( UUID organizationId, UserInfo user ) throws
Exception {
-        if (properties.newAdminUsersRequireConfirmation()) {
             String token = getConfirmationTokenForAdminUser(user.getUuid(), 0, organizationId);
             OrganizationConfig orgConfig = organizationId != null ?
                 getOrganizationConfigByUuid(organizationId) : getOrganizationConfigForUserInfo(user);
@@ -2656,7 +2660,6 @@ public class ManagementServiceImpl implements ManagementService {
             sendAdminUserEmail(user, "User Account Confirmation: " + user.getEmail(),
                 emailMsg(hashMap("confirm_email", user.getEmail()).map("confirmation_url",
confirmation_url),
                     PROPERTIES_EMAIL_ADMIN_CONFIRMATION));
-        }
     }
 
 


Mime
View raw message