[Rt-commit] rt branch 4.4/add-clean-sessions-all-option created. rt-4.4.5-23-g0a38e522da

BPS Git Server git at git.bestpractical.com
Thu Jan 27 23:47:42 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 4.4/add-clean-sessions-all-option has been created
        at  0a38e522da13642649257dd7f1819e5c28e646a8 (commit)

- Log -----------------------------------------------------------------
commit 0a38e522da13642649257dd7f1819e5c28e646a8
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Jan 27 15:43:44 2022 -0800

    Add clean-all option

diff --git a/sbin/rt-clean-sessions.in b/sbin/rt-clean-sessions.in
index f4c0df2c36..96eb33e76d 100644
--- a/sbin/rt-clean-sessions.in
+++ b/sbin/rt-clean-sessions.in
@@ -68,7 +68,7 @@ BEGIN { # BEGIN RT CMD BOILERPLATE
 
 use Getopt::Long;
 my %opt;
-GetOptions( \%opt, "older=s", "debug", "help|h", "skip-user" );
+GetOptions( \%opt, "older=s", "debug", "help|h", "skip-user", "clean-all" );
 
 
 if ( $opt{help} ) {
@@ -117,7 +117,7 @@ if ( $opt{'older'} or $alogoff ) {
     RT::Interface::Web::Session->ClearOld( $min );
 }
 
-RT::Interface::Web::Session->ClearByUser
+RT::Interface::Web::Session->ClearByUser( $opt{'clean-all'} )
     unless $opt{'skip-user'};
 
 exit(0);
@@ -130,13 +130,14 @@ rt-clean-sessions - clean old and duplicate RT sessions
 
 =head1 SYNOPSIS
 
-     rt-clean-sessions [--debug] [--older <NUM>[H|D|M|Y]]
+     rt-clean-sessions [--debug] [--older <NUM>[H|D|M|Y]] [--skip-user] [--clean-all]
 
      rt-clean-sessions
      rt-clean-sessions --debug
      rt-clean-sessions --older 10D
      rt-clean-sessions --debug --older 1M
      rt-clean-sessions --older 10D --skip-user
+     rt-clean-sessions --clean-all
 
 =head1 DESCRIPTION
 
@@ -164,6 +165,12 @@ By default only one session per user left in the DB, so users that have
 sessions on multiple computers or in different browsers will be logged out.
 Use this option to avoid this.
 
+=item clean-all
+
+Use this option to clear all sessions.
+
+If the --skip-user option is used then the --clean-all option has no effect.
+
 =item debug
 
 Turn on debug output.

commit dc4cc455cf30dc2d31ff352c9558badb8a79928a
Author: Brad Embree <brad at bestpractical.com>
Date:   Thu Jan 27 15:42:30 2022 -0800

    Add optional clear_all parameter to ClearByUser method

diff --git a/lib/RT/Interface/Web/Session.pm b/lib/RT/Interface/Web/Session.pm
index 3b56e42486..d31677230e 100644
--- a/lib/RT/Interface/Web/Session.pm
+++ b/lib/RT/Interface/Web/Session.pm
@@ -284,12 +284,14 @@ sub ClearOrphanLockFiles {
 =head3 ClearByUser
 
 Checks all sessions and if user has more then one session
-then leave only the latest one.
+then leave only the latest one unless optional clear all
+parameter is true then delete all.
 
 =cut
 
 sub ClearByUser {
     my $self = shift || __PACKAGE__;
+    my $clear_all = shift;
     my $class = $self->Class;
     my $attrs = $self->Attributes;
 
@@ -304,7 +306,7 @@ sub ClearByUser {
             next;
         }
         if( $session{'CurrentUser'} && $session{'CurrentUser'}->id ) {
-            unless( $seen{ $session{'CurrentUser'}->id }++ ) {
+            unless( $clear_all || $seen{ $session{'CurrentUser'}->id }++ ) {
                 $RT::Logger->debug("skipped session '$id', first user's session");
                 next;
             }

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list