Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Use 'configure' permission for configuring navs #9961

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function edit($nav)
{
$nav = Nav::find($nav);

$this->authorize('edit', $nav, __('You are not authorized to configure navs.'));
$this->authorize('configure', $nav, __('You are not authorized to configure navs.'));

$values = [
'title' => $nav->title(),
Expand Down
5 changes: 5 additions & 0 deletions src/Policies/NavPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public function store($user)
// handled by before()
}

public function configure($user)
{
// handled by before()
}

public function view($user, $nav)
{
$user = User::fromUser($user);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Navigation/EditNavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class EditNavigationTest extends TestCase
use PreventSavingStacheItemsToDisk;

/** @test */
public function it_shows_the_edit_form_if_user_has_edit_permission()
public function it_shows_the_edit_form_if_user_has_configure_permission()
{
$nav = $this->createNav('foo');
Nav::shouldReceive('all')->andReturn(collect([$nav]));
Nav::shouldReceive('find')->andReturn($nav);

$this->setTestRoles(['test' => ['access cp', 'edit foo nav']]);
$this->setTestRoles(['test' => ['access cp', 'configure navs']]);
$user = Facades\User::make()->assignRole('test')->save();

$response = $this
Expand All @@ -32,7 +32,7 @@ public function it_shows_the_edit_form_if_user_has_edit_permission()
}

/** @test */
public function it_denies_access_if_user_doesnt_have_edit_permission()
public function it_denies_access_if_user_doesnt_have_configure_permission()
{
$nav = $this->createNav('foo');
Nav::shouldReceive('all')->andReturn(collect([$nav]));
Expand Down
Loading