-
app/Policies/HandlesPackageAuthorizationTrait.php
Open in GitHubtrait HandlesPackageAuthorizationTrait { protected function userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $package) { return $user->isAdmin() || $this->userIsPackageAuthor($user, $package) || $this->userIsPackageCollaborator($user, $package) || $this->userIsUnclaimedPackageSubmitter($user, $package); } }
-
app/Policies/PackagePolicy.php
Open in GitHubuse App\Package; use App\Policies\HandlesPackageAuthorizationTrait; class PackagePolicy { use HandlesPackageAuthorizationTrait; public function show(User $user, Package $package) { return $this->userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $package); } public function update(User $user, Package $package) { return $this->userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $package); } }
-
app/Policies/ScreenshotPolicy.php
Open in GitHubuse App\Policies\HandlesPackageAuthorizationTrait; use App\Screenshot; use App\User; class ScreenshotPolicy { use HandlesPackageAuthorizationTrait; public function delete(User $user, Screenshot $screenshot) { if ($screenshot->uploader->is($user) || ($screenshot->hasPackage() && $this->userIsAdminOrAuthorOrCollaboratorOrUnclaimedSubmitter($user, $screenshot->package)) ) { return true; } return false; } }