Mailing List Archive

rt branch 5.0/fix-default-catalog-on-asset-creation created. rt-5.0.5-163-gbb751418b5
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, 5.0/fix-default-catalog-on-asset-creation has been created
at bb751418b557c7caa19f32b7de29e2e72859dcd7 (commit)

- Log -----------------------------------------------------------------
commit bb751418b557c7caa19f32b7de29e2e72859dcd7
Author: Ronaldo Richieri <ronaldo@bestpractical.com>
Date: Mon Mar 11 18:00:46 2024 -0300

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.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index e47fa96069..cfb8c29317 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;
}

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


hooks/post-receive
--
rt
_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
https://lists.bestpractical.com/mailman/listinfo/rt-commit