Skip to content

Commit

Permalink
Load the first catalog current user can create assets in on asset cre…
Browse files Browse the repository at this point in the history
…ate page

Previously if current user can't create assets on the default catalog(either
$DefaultCatalog or the first catalog they can see), they would get the
"Permission Denied" error directly and couldn't pick catalogs at all. This
commit tries a bit harder to find a catalog current user can create assets
in, before returning the "Permission Denied" error.
  • Loading branch information
sunnavy committed Mar 12, 2024
1 parent cf34cad commit bdbdf0c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions share/html/Asset/Create.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@
my $asset = RT::Asset->new( $session{CurrentUser} );
my $catalog = LoadDefaultCatalog( $Catalog || '' );

if ( !$Catalog && ( !$catalog->id || !$catalog->CurrentUserHasRight('CreateAsset') ) ) {
my $cache_key = SetObjectSessionCache(
ObjectType => 'Catalog',
CheckRight => 'CreateAsset',
CacheNeedsUpdate => RT::Catalog->CacheNeedsUpdate,
ShowAll => 0,
);

if ( $session{$cache_key}{objects}[0] ) {
$catalog->Load( $session{$cache_key}{objects}[0]->{Id} );
}
}

Abort(loc("Unable to find catalog '[_1]'", $Catalog))
unless $catalog->id;

Expand Down

0 comments on commit bdbdf0c

Please sign in to comment.