From bb751418b557c7caa19f32b7de29e2e72859dcd7 Mon Sep 17 00:00:00 2001 From: Ronaldo Richieri Date: Mon, 11 Mar 2024 18:00:46 -0300 Subject: [PATCH] Display first accessible catalog when default unset Users were wrongly receiving a permission denied error when no default catalog was set on their account or if the default catalog of the system was one that they did not have access to, or even if there was not default catalog set on the system. This change will show the first available catalog for the user when no default catalog is set based on the catalogs that the user has access to create assets in. --- lib/RT/Interface/Web.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm index e47fa96069d..cfb8c293174 100644 --- a/lib/RT/Interface/Web.pm +++ b/lib/RT/Interface/Web.pm @@ -4634,8 +4634,11 @@ sub LoadDefaultCatalog { # If no catalog, default to the first active catalog my $catalogs = RT::Catalogs->new($session{CurrentUser}); $catalogs->UnLimit; - my $candidate = $catalogs->First; - $catalog_obj = $candidate if $candidate; + while ( my $catalog = $catalogs->Next ) { + next unless $catalog->CurrentUserHasRight('CreateAsset'); + $catalog_obj = $catalog; + last; + } RT::Logger->error("No active catalogs.") unless $catalog_obj and $catalog_obj->Id; }