[Rt-commit] rt branch 5.0/default-catalog-on-asset-create created. rt-5.0.5-163-gbdbdf0cbea
BPS Git Server
git at git.bestpractical.com
Tue Mar 12 14:38:54 UTC 2024
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/default-catalog-on-asset-create has been created
at bdbdf0cbea4300b397a634370df4b4a1ede87612 (commit)
- Log -----------------------------------------------------------------
commit bdbdf0cbea4300b397a634370df4b4a1ede87612
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Mar 12 10:16:30 2024 -0400
Load the first catalog current user can create assets in on asset create 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.
diff --git a/share/html/Asset/Create.html b/share/html/Asset/Create.html
index 5042609cf5..db69fd3c31 100644
--- a/share/html/Asset/Create.html
+++ b/share/html/Asset/Create.html
@@ -110,6 +110,19 @@ $Catalog => undef
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;
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list