Skip to content

Commit

Permalink
Fix policy with users in database
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Nov 24, 2023
1 parent 69d82fb commit 1cdbd11
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Policies/SeoVariablesPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
namespace Aerni\AdvancedSeo\Policies;

use Aerni\AdvancedSeo\Models\Defaults;
use Statamic\Contracts\Auth\User;
use Statamic\Facades\User as UserFacade;
use Statamic\Facades\User;

class SeoVariablesPolicy
{
public function index(User $user, string $type): bool
public function index($user, string $type): bool
{
return Defaults::enabledInType($type)->map->handle
->filter(fn ($type) => $this->view($user, $type))
->isNotEmpty();
}

public function view(User $user, string $type): bool
public function view($user, string $type): bool
{
$user = UserFacade::fromUser($user);
$user = User::fromUser($user);

return $user->hasPermission("view seo {$type} defaults");
}

public function edit(User $user, string $type): bool
public function edit($user, string $type): bool
{
$user = UserFacade::fromUser($user);
$user = User::fromUser($user);

return $user->hasPermission("edit seo {$type} defaults");
}
Expand Down

0 comments on commit 1cdbd11

Please sign in to comment.