Skip to content

Commit feeeb13

Browse files
committed
Drop user contract type hint from gate and policy methods
When the eloquent users repository is used, Laravel's Gate dispatches the host app's Authenticatable model (e.g. App\Models\User), which doesn't implement Statamic\Contracts\Auth\User. UserFacade::fromUser() already converts any Authenticatable into the contract before checks, so the type hints just blocked non-super users from the SEO pages. Fixes #108.
1 parent c2466ef commit feeeb13

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/Gates/SeoContentGate.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
use Aerni\AdvancedSeo\AdvancedSeo;
66
use Aerni\AdvancedSeo\SeoSets\SeoSet;
7-
use Statamic\Contracts\Auth\User;
87
use Statamic\Facades\User as UserFacade;
98

109
class SeoContentGate
1110
{
1211
/**
1312
* Determine if the user can access the SEO tab and edit content on entries and terms.
1413
*/
15-
public function editContent(User $user, SeoSet $seoSet): bool
14+
public function editContent($user, SeoSet $seoSet): bool
1615
{
1716
if (! AdvancedSeo::pro()) {
1817
return true;

src/Policies/SeoSetPolicy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SeoSetPolicy
1414
{
1515
use HasMultisitePolicy;
1616

17-
public function before(User $user)
17+
public function before($user)
1818
{
1919
if (! AdvancedSeo::pro()) {
2020
return true;
@@ -27,7 +27,7 @@ public function before(User $user)
2727
}
2828
}
2929

30-
public function viewAny(User $user, SeoSetGroup $group): bool
30+
public function viewAny($user, SeoSetGroup $group): bool
3131
{
3232
$user = UserFacade::fromUser($user);
3333

@@ -36,7 +36,7 @@ public function viewAny(User $user, SeoSetGroup $group): bool
3636
});
3737
}
3838

39-
public function edit(User $user, SeoSetLocalization $localization): bool
39+
public function edit($user, SeoSetLocalization $localization): bool
4040
{
4141
$user = UserFacade::fromUser($user);
4242

@@ -54,7 +54,7 @@ public function edit(User $user, SeoSetLocalization $localization): bool
5454
return $canEditLocalization && $this->canEditStatamicContent($user, $localization->type(), $localization->handle());
5555
}
5656

57-
public function configure(User $user, SeoSet $seoSet): bool
57+
public function configure($user, SeoSet $seoSet): bool
5858
{
5959
$user = UserFacade::fromUser($user);
6060

0 commit comments

Comments
 (0)