[Bps-public-commit] rt-extension-resetpassword branch, show-user-password-status, created. 1.10-1-g308cbcb

Jim Brandt jbrandt at bestpractical.com
Tue Apr 13 13:46:29 EDT 2021


The branch, show-user-password-status has been created
        at  308cbcba2066ee9f8f3b3f32f4ddabd2c3371cf0 (commit)

- Log -----------------------------------------------------------------
commit 308cbcba2066ee9f8f3b3f32f4ddabd2c3371cf0
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Apr 13 13:42:11 2021 -0400

    Add an option to show all users with a password set

diff --git a/README b/README
index a8a2d7c..876143a 100644
--- a/README
+++ b/README
@@ -22,6 +22,12 @@ INSTALLATION
     make install
         May need root permissions
 
+    Install Patches
+        For RT 5.0.0 and 5.0.1 only, apply this patch to enable searches for
+        users with a password set. See below for details.
+
+            patch -p1 -d /opt/rt5 < patches/user-admin-callbacks.patch
+
     make initdb
         Only run this the first time you install this module.
 
@@ -108,6 +114,13 @@ CONFIGURATION
         currently has a password set. The "Delete password" option allows
         you to clear passwords if a user should no longer have access.
 
+        For RT 5 only, this extension also adds a checkbox to the user admin
+        page that allows you to filter users, displaying only those who have
+        a password set. If you disable the $AllowUsersWithoutPassword
+        option, this checkbox allows you to see all users who have an
+        existing password and would therefore be able to reset their
+        password.
+
     $CreateNewUserAsPrivileged
         Set this config value to true if users creating a new account should
         default to privileged users.
diff --git a/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/InUsersAdminForm b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/InUsersAdminForm
new file mode 100644
index 0000000..aef3798
--- /dev/null
+++ b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/InUsersAdminForm
@@ -0,0 +1,8 @@
+  <div class="form-row">
+    <div class="col-12">
+      <div class="custom-control custom-checkbox">
+        <input type="checkbox" class="custom-control-input checkbox" id="FindUsersWithPassword" name="FindUsersWithPassword" value="1" <% $ARGS{'FindUsersWithPassword'} ? 'checked="checked"': '' %> />
+        <label class="custom-control-label" for="FindUsersWithPassword"><&|/l&>List users with a password set.</&></label>
+      </div>
+    </div>
+  </div>
diff --git a/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/Initial b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/Initial
new file mode 100644
index 0000000..124f8e7
--- /dev/null
+++ b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/Initial
@@ -0,0 +1,32 @@
+<%init>
+
+if ( $ARGSRef->{'FindUsersWithPassword'} ) {
+    # The options below align with the values checked by RT::User::HasPassword
+    $UsersObj->Limit(
+        FIELD => 'Password',
+        OPERATOR => '!=',
+        VALUE => '*NO-PASSWORD*',
+        ENTRYAGGREGATOR => 'AND',
+        SUBCLAUSE => 'nopassword',
+    );
+    $UsersObj->Limit(
+        FIELD => 'Password',
+        OPERATOR => '!=',
+        VALUE => '',
+        ENTRYAGGREGATOR => 'AND',
+        SUBCLAUSE => 'nopassword',
+    );
+    $UsersObj->Limit(
+        FIELD => 'Password',
+        OPERATOR => 'IS NOT',
+        VALUE => 'NULL',
+        ENTRYAGGREGATOR => 'AND',
+        SUBCLAUSE => 'nopassword',
+    );
+}
+
+</%init>
+<%args>
+$UsersObj
+$ARGSRef
+</%args>
diff --git a/lib/RT/Extension/ResetPassword.pm b/lib/RT/Extension/ResetPassword.pm
index c10ccc7..6c03e05 100644
--- a/lib/RT/Extension/ResetPassword.pm
+++ b/lib/RT/Extension/ResetPassword.pm
@@ -116,6 +116,13 @@ Works with RT 4.0, 4.2, 4.4, 5.0
 
 May need root permissions
 
+=item Install Patches
+
+For RT 5.0.0 and 5.0.1 only, apply this patch to enable searches for users
+with a password set. See below for details.
+
+    patch -p1 -d /opt/rt5 < patches/user-admin-callbacks.patch
+
 =item C<make initdb>
 
 Only run this the first time you install this module.
@@ -211,6 +218,12 @@ section on the user admin page which shows whether the user currently
 has a password set. The "Delete password" option allows you to clear
 passwords if a user should no longer have access.
 
+For RT 5 only, this extension also adds a checkbox to the user admin
+page that allows you to filter users, displaying only those who have
+a password set. If you disable the C<$AllowUsersWithoutPassword> option,
+this checkbox allows you to see all users who have an existing password
+and would therefore be able to reset their password.
+
 =item C<$CreateNewUserAsPrivileged>
 
 Set this config value to true if users creating a new account should
diff --git a/patches/user-admin-callbacks.patch b/patches/user-admin-callbacks.patch
new file mode 100644
index 0000000..0ad771e
--- /dev/null
+++ b/patches/user-admin-callbacks.patch
@@ -0,0 +1,31 @@
+commit a3ba1f81d3eb057e08636e1fbbd25c24beaae72f
+Author: Jim Brandt <jbrandt at bestpractical.com>
+Date:   Mon Apr 12 17:16:10 2021 -0400
+
+    Add callbacks to user admin index page
+    
+    These allow a developer to add a custom component to the
+    form and then act on it in the init section.
+
+diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
+index 4bcfc2e95..e819b3393 100644
+--- a/share/html/Admin/Users/index.html
++++ b/share/html/Admin/Users/index.html
+@@ -129,6 +129,8 @@ jQuery(function(){
+     </div>
+   </div>
+ 
++% $m->callback( %ARGS, UsersObj => $users, CallbackName => 'InUsersAdminForm' );
++
+   <div class="form-row">
+     <div class="col-12 text-right">
+       <input type="submit" class="button btn btn-primary" value="<&|/l&>Go!</&>" name="Go" />
+@@ -159,6 +161,8 @@ my $caption;
+ my $users = RT::Users->new( $session{'CurrentUser'} );
+ $users->FindAllRows if $FindDisabledUsers;
+ 
++$m->callback( UsersObj => $users, ARGSRef => \%ARGS, CallbackName => 'Initial' );
++
+ $caption = loc("Users matching search criteria");
+ my @users_queries = ();
+ push @users_queries, { field => $UserField, op => $UserOp, string => $UserString } if length $UserString;

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


More information about the Bps-public-commit mailing list