Skip to content

Commit ba02697

Browse files
committed
More fixes
1 parent 89bab08 commit ba02697

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/Element/Concerns/Draftable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace CraftCms\Cms\Element\Concerns;
66

7+
use Craft;
78
use craft\elements\User as UserElement;
89
use CraftCms\Cms\Database\Table;
910
use CraftCms\Cms\Element\Events\AuthorizeCreateDrafts;
10-
use CraftCms\Cms\User\Models\User;
1111
use Illuminate\Support\Facades\DB;
1212
use Illuminate\Support\Facades\Event;
1313

@@ -127,7 +127,7 @@ public function handleDraftDelete(): void
127127
/**
128128
* {@inheritdoc}
129129
*/
130-
public function canCreateDrafts(User $user): bool
130+
public function canCreateDrafts(UserElement $user): bool
131131
{
132132
if (Event::hasListeners(AuthorizeCreateDrafts::class)) {
133133
Event::dispatch($event = new AuthorizeCreateDrafts($this, $user));
@@ -144,7 +144,7 @@ public function canCreateDrafts(User $user): bool
144144
public function canDuplicateAsDraft(UserElement $user): bool
145145
{
146146
// if anything, this will be more lenient than canDuplicate()
147-
return \Craft::$app->getElements()->canDuplicate($this, $user);
147+
return Craft::$app->getElements()->canDuplicate($this, $user);
148148
}
149149

150150
/**

src/Element/Events/AuthorizeCreateDrafts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace CraftCms\Cms\Element\Events;
66

77
use craft\base\ElementInterface;
8-
use CraftCms\Cms\User\Models\User;
8+
use craft\elements\User;
99

1010
final class AuthorizeCreateDrafts
1111
{

yii2-adapter/legacy/base/Element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3799,7 +3799,7 @@ public function canCreateDrafts(User $user): bool
37993799
return $event->authorized;
38003800
}
38013801

3802-
return $this->traitCanCreateDrafts(\CraftCms\Cms\User\Models\User::findOrFail($user->id));
3802+
return $this->traitCanCreateDrafts($user);
38033803
}
38043804

38053805
/**

yii2-adapter/src/Web/User.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function getIdentity($autoRenew = true)
2424
return $this->_identity;
2525
}
2626

27-
$identity = $this->getIlluminateAuthManager()->user();
27+
$identity = $this->getIlluminateAuthManager()->guard('craft')->user();
2828

2929
if ($identity !== null) {
3030
$identity = $this->convertIlluminateIdentity($identity);
@@ -58,7 +58,7 @@ public function switchIdentity($identity, $duration = 0): void
5858
$this->setIdentity($identity);
5959

6060
if ($identity === null) {
61-
$this->getIlluminateAuthManager()->logout();
61+
$this->getIlluminateAuthManager()->guard('craft')->logout();
6262

6363
return;
6464
}
@@ -73,7 +73,7 @@ public function switchIdentity($identity, $duration = 0): void
7373
* When "Remember me for 2 weeks" is checked, the duration will be larger
7474
* than 3600, so we pass remember to Laravel's auth as well.
7575
*/
76-
$this->getIlluminateAuthManager()->loginUsingId($id, remember: $duration > 3600);
76+
$this->getIlluminateAuthManager()->guard('craft')->loginUsingId($id, remember: $duration > 3600);
7777
}
7878

7979
protected function convertIlluminateIdentity(mixed $identity): IdentityInterface

0 commit comments

Comments
 (0)