File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public function repository($key = null)
4343 ]), 404 );
4444 }
4545
46- if (! $ repository ::authorizedToShowAny ($ this )) {
46+ if (! $ repository ::authorizedToShowRepository ($ this )) {
4747 throw new UnauthorizedException (__ ('Unauthorized to view repository :name. ' , [
4848 'name ' => $ repository ,
4949 ]), 403 );
Original file line number Diff line number Diff line change @@ -69,6 +69,23 @@ public static function authorizedToShowAny(Request $request)
6969 : true ;
7070 }
7171
72+ /**
73+ * Determine if the repository url is available
74+ *
75+ * @param \Illuminate\Http\Request $request
76+ * @return bool
77+ */
78+ public static function authorizedToShowRepository (Request $ request )
79+ {
80+ if (! static ::authorizable ()) {
81+ return true ;
82+ }
83+
84+ return method_exists (Gate::getPolicyFor (static ::newModel ()), 'showRepository ' )
85+ ? Gate::check ('showRepository ' , get_class (static ::newModel ()))
86+ : true ;
87+ }
88+
7289 /**
7390 * Determine if the current user can view the given resource or throw.
7491 *
You can’t perform that action at this time.
0 commit comments