1 | <?php declare(strict_types=1); |
||
16 | class Impersonator |
||
17 | { |
||
18 | /** @var Guard $guard */ |
||
19 | protected $guard; |
||
20 | |||
21 | /** @var Repository $config */ |
||
22 | protected $config; |
||
23 | |||
24 | /** @var UserProvider */ |
||
25 | protected $userProvider; |
||
26 | |||
27 | /** @var Store $session */ |
||
28 | protected $session; |
||
29 | |||
30 | /** @var Dispatcher $eventDispatcher */ |
||
31 | protected $eventDispatcher; |
||
32 | |||
33 | /** @var Authenticatable */ |
||
34 | protected $realUser; |
||
35 | |||
36 | /** @var Authenticatable */ |
||
37 | protected $impersonationUser; |
||
38 | |||
39 | /** @var bool */ |
||
40 | protected $isForbidden; |
||
41 | |||
42 | const SESSION_NAME = 'pretend:_switch_user'; |
||
43 | |||
44 | 7 | public function __construct( |
|
59 | |||
60 | /** |
||
61 | * @throws HttpException Throw 403 exception if cannot find user |
||
62 | */ |
||
63 | 1 | public function exitImpersonation() |
|
78 | |||
79 | /** |
||
80 | * @throws HttpException Throw 403 exception if cannot find user |
||
81 | */ |
||
82 | 4 | protected function retrieveUser(string $username): Authenticatable |
|
96 | |||
97 | /** |
||
98 | * @throws HttpException Throw 403 exception if you try to impersonate yourself |
||
99 | * |
||
100 | * @param string $username Username of user you want to enter impersonate |
||
101 | */ |
||
102 | 4 | public function enterImpersonation(string $username) |
|
119 | |||
120 | 4 | public function isImpersonated(): bool |
|
124 | |||
125 | /** |
||
126 | * @throws HttpException Throw 403 exception if cannot find data in session |
||
127 | */ |
||
128 | public function continueImpersonation() |
||
134 | |||
135 | public function getImpersonatingIdentifier(): string |
||
139 | } |
||
140 |