[Bps-public-commit] rt-extension-resetpassword branch, master, updated. 1.10-2-ga6ed913

? sunnavy sunnavy at bestpractical.com
Thu Apr 22 15:45:06 EDT 2021


The branch, master has been updated
       via  a6ed91367662b6afde810d3154fac73954287047 (commit)
       via  7bd68f045232c9d6604712769da70bc806993886 (commit)
      from  f8303135e445ac3807be2b2c3ca09f5cb10cd878 (commit)

Summary of changes:
 README                                             | 13 +++++++++
 .../Admin/Users/index.html/InUsersAdminForm        |  8 ++++++
 .../Admin/Users/index.html/Initial                 | 32 ++++++++++++++++++++++
 lib/RT/Extension/ResetPassword.pm                  | 13 +++++++++
 patches/user-admin-callbacks.patch                 | 31 +++++++++++++++++++++
 5 files changed, 97 insertions(+)
 create mode 100644 html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/InUsersAdminForm
 create mode 100644 html/Callbacks/RT-Extension-ResetPassword/Admin/Users/index.html/Initial
 create mode 100644 patches/user-admin-callbacks.patch

- Log -----------------------------------------------------------------
commit 7bd68f045232c9d6604712769da70bc806993886
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..b8d7b15
--- /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',
+    ) if RT->Config->Get('DatabaseType') ne 'Oracle';
+    $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;

commit a6ed91367662b6afde810d3154fac73954287047
Merge: f830313 7bd68f0
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Apr 23 03:44:16 2021 +0800

    Merge branch 'show-user-password-status'


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


More information about the Bps-public-commit mailing list