Skip to content

Commit

Permalink
fix permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
abourtnik committed Mar 29, 2024
1 parent c71e9c3 commit d3a6c9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/Policies/CommentPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function viewAny(User $user) : Response|bool

public function list(?User $user, Video $video) : Response|bool
{
if ($user?->is_admin) {
return Response::allow();
}

return ($video->is_public && $video->allow_comments) || $video->user()->is($user)
? Response::allow()
: Response::denyWithStatus(404, !$video->is_public ? 'This video is private' : 'Comments are turned off');
Expand Down
6 changes: 5 additions & 1 deletion app/Policies/VideoPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function view(User $user, Video $video): Response|bool
*/
public function show(?User $user, Video $video): Response|bool
{
if ($user->is_admin) {
if ($user?->is_admin) {
return Response::allow();
}

Expand Down Expand Up @@ -79,6 +79,10 @@ public function download(User $user, Video $video): Response|bool
*/
public function file(?User $user, Video $video): Response|bool
{
if ($user?->is_admin) {
return Response::allow();
}

return $video->is_public || $video->user()->is($user)
? Response::allow()
: Response::denyWithStatus(403, 'This video is private');
Expand Down

0 comments on commit d3a6c9f

Please sign in to comment.