1 | <?php |
||
10 | class ImpersonateManager |
||
11 | { |
||
12 | const REMEMBER_PREFIX = 'remember_web'; |
||
13 | |||
14 | /** |
||
15 | * @var Application |
||
16 | */ |
||
17 | private $app; |
||
18 | |||
19 | /** |
||
20 | * UserFinder constructor. |
||
21 | * |
||
22 | * @param Application $app |
||
23 | */ |
||
24 | public function __construct(Application $app) |
||
25 | { |
||
26 | $this->app = $app; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param int $id |
||
31 | * @return Model |
||
32 | */ |
||
33 | public function findUserById($id) |
||
34 | { |
||
35 | $model = $this->app['config']->get('auth.providers.users.model'); |
||
36 | |||
37 | $user = call_user_func([ |
||
38 | $model, |
||
39 | 'findOrFail' |
||
40 | ], $id); |
||
41 | |||
42 | return $user; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function isImpersonating() |
||
52 | |||
53 | /** |
||
54 | * @param void |
||
55 | * @return int|null |
||
56 | */ |
||
57 | public function getImpersonatorId() |
||
61 | |||
62 | /** |
||
63 | * @param Model $from |
||
64 | * @param Model $to |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function take($from, $to) |
||
86 | |||
87 | /** |
||
88 | * @return bool |
||
89 | */ |
||
90 | public function leave() |
||
113 | |||
114 | /** |
||
115 | * @return void |
||
116 | */ |
||
117 | public function clear() |
||
121 | |||
122 | /** |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getSessionKey() |
||
129 | |||
130 | /** |
||
131 | * @return string |
||
132 | */ |
||
133 | public function getTakeRedirectTo() |
||
143 | |||
144 | /** |
||
145 | * @return string |
||
146 | */ |
||
147 | public function getLeaveRedirectTo() |
||
157 | |||
158 | /** |
||
159 | * @return void |
||
160 | */ |
||
161 | protected function saveAuthCookieInSession() |
||
176 | |||
177 | /** |
||
178 | * @return void |
||
179 | */ |
||
180 | protected function extractAuthCookieFromSession() |
||
189 | |||
190 | /** |
||
191 | * @param array $values |
||
192 | * @param string $search |
||
193 | * @return \Illuminate\Support\Collection |
||
194 | */ |
||
195 | protected function findByKeyInArray(array $values, string $search) |
||
202 | } |
||
203 |