[Bps-public-commit] rt-authen-externalauth branch, dont-disable-disabled-user, created. 0.09-1-g4b69d20

Ruslan Zakirov ruz at bestpractical.com
Tue May 24 17:09:07 EDT 2011


The branch, dont-disable-disabled-user has been created
        at  4b69d20873581110ea3d50ac999ac4aa65bd75f4 (commit)

- Log -----------------------------------------------------------------
commit 4b69d20873581110ea3d50ac999ac4aa65bd75f4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 25 01:06:25 2011 +0400

    cleanup disabling and enabling users on info update
    
    * don't SetDisabled if new value match old one
    * abort update if we can not enable user that is
      disabled in RT
    
    Thanks to Andrew W Daugherity.

diff --git a/lib/RT/Authen/ExternalAuth.pm b/lib/RT/Authen/ExternalAuth.pm
index f07e17f..e746b61 100644
--- a/lib/RT/Authen/ExternalAuth.pm
+++ b/lib/RT/Authen/ExternalAuth.pm
@@ -256,25 +256,32 @@ sub UpdateUserInfo {
     # then I'll update all the info for disabled users
 
     if ($user_disabled) {
-        # Make sure principle is disabled in RT
-        my ($val, $message) = $UserObj->SetDisabled(1);
-        # Log what has happened
-        $RT::Logger->info("User marked as DISABLED (",
-                            $username,
-                            ") per External Service", 
-                            "($val, $message)\n");
-        $msg = "User Disabled";
-        
+        unless ( $UserObj->Disabled ) {
+            # Make sure principle is disabled in RT
+            my ($val, $message) = $UserObj->SetDisabled(1);
+            # Log what has happened
+            $RT::Logger->info("User marked as DISABLED (",
+                                $username,
+                                ") per External Service", 
+                                "($val, $message)\n");
+            $msg = "User Disabled";
+        }
+
         return ($updated, $msg);
     }    
         
     # Make sure principle is not disabled in RT
-    my ($val, $message) = $UserObj->SetDisabled(0);
-    # Log what has happened
-    $RT::Logger->info("User marked as ENABLED (",
-                        $username,
-                        ") per External Service",
+    if ( $UserObj->Disabled ) {
+        my ($val, $message) = $UserObj->SetDisabled(0);
+        unless ( $val ) {
+            $RT::Logger->error("Failed to enable user ($username) per External Service: $message");
+            return ($updated, "Failed to enable");
+        }
+
+        $RT::Logger->info("User ($username) was disabled, marked as ENABLED ",
+                        "per External Service",
                         "($val, $message)\n");
+    }
 
     # Update their info from external service using the username as the lookup key
     # CanonicalizeUserInfo will work out for itself which service to use

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list