mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Fix forum category views
This commit is contained in:
@@ -79,6 +79,9 @@ class CategoryPolicy extends \TeamTeaTime\Forum\Policies\CategoryPolicy
|
||||
|
||||
private function canViewCategory(mixed $user): bool
|
||||
{
|
||||
return $user instanceof User && $user->hasAnyRole(['Admin', 'Moderator']);
|
||||
// Forum v8 applies category view checks when filtering private category trees.
|
||||
// Allow any authenticated forum user to see categories while keeping category
|
||||
// management actions restricted to admins.
|
||||
return $user instanceof User;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Policies\CategoryPolicy;
|
||||
use App\Policies\PostPolicy;
|
||||
use App\Policies\ThreadPolicy;
|
||||
@@ -28,6 +29,15 @@ final class ForumGuestPolicyTest extends TestCase
|
||||
$this->assertFalse($policy->view(null, $category));
|
||||
}
|
||||
|
||||
public function test_authenticated_non_staff_user_can_view_categories(): void
|
||||
{
|
||||
$policy = new CategoryPolicy;
|
||||
$category = new Category;
|
||||
$user = new User;
|
||||
|
||||
$this->assertTrue($policy->view($user, $category));
|
||||
}
|
||||
|
||||
public function test_guest_thread_actions_are_denied_but_threads_remain_viewable(): void
|
||||
{
|
||||
$policy = new ThreadPolicy;
|
||||
|
||||
Reference in New Issue
Block a user