Skip to content

Commit

Permalink
Display first accessible catalog when default unset
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
richieri-bps committed Mar 11, 2024
1 parent cf34cad commit bb75141
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/RT/Interface/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit bb75141

Please sign in to comment.