|
3 | 3 | namespace CodeIgniter\Shield\Authentication\Authenticators; |
4 | 4 |
|
5 | 5 | use CodeIgniter\Events\Events; |
| 6 | +use CodeIgniter\HTTP\IncomingRequest; |
| 7 | +use CodeIgniter\HTTP\Response; |
6 | 8 | use CodeIgniter\I18n\Time; |
7 | 9 | use CodeIgniter\Shield\Authentication\AuthenticationException; |
8 | 10 | use CodeIgniter\Shield\Authentication\AuthenticatorInterface; |
@@ -60,7 +62,9 @@ public function remember(bool $shouldRemember = true) |
60 | 62 | */ |
61 | 63 | public function attempt(array $credentials) |
62 | 64 | { |
63 | | - $request = service('request'); |
| 65 | + /** @var IncomingRequest $request */ |
| 66 | + $request = service('request'); |
| 67 | + |
64 | 68 | $ipAddress = $request->getIPAddress(); |
65 | 69 | $userAgent = $request->getUserAgent(); |
66 | 70 | $result = $this->check($credentials); |
@@ -116,10 +120,10 @@ public function check(array $credentials) |
116 | 120 | ]); |
117 | 121 | } |
118 | 122 |
|
119 | | - // Now, try matching the passwords. |
120 | 123 | /** @var Passwords $passwords */ |
121 | 124 | $passwords = service('passwords'); |
122 | 125 |
|
| 126 | + // Now, try matching the passwords. |
123 | 127 | if (! $passwords->verify($givenPassword, $user->password_hash)) { |
124 | 128 | return new Result([ |
125 | 129 | 'success' => false, |
@@ -190,8 +194,11 @@ public function login(Authenticatable $user) |
190 | 194 | // Let the session know we're logged in |
191 | 195 | session()->set(setting('Auth.sessionConfig')['field'], $this->user->getAuthId()); |
192 | 196 |
|
| 197 | + /** @var Response $response */ |
| 198 | + $response = service('response'); |
| 199 | + |
193 | 200 | // When logged in, ensure cache control headers are in place |
194 | | - service('response')->noCache(); |
| 201 | + $response->noCache(); |
195 | 202 |
|
196 | 203 | if ($this->shouldRemember && setting('Auth.sessionConfig')['allowRemembering']) { |
197 | 204 | $this->rememberUser($this->user->getAuthId()); |
@@ -330,9 +337,10 @@ protected function rememberUser($userId): void |
330 | 337 | // Store it in the database |
331 | 338 | $this->rememberModel->rememberUser($userId, $selector, hash('sha256', $validator), $expires); |
332 | 339 |
|
333 | | - // Save it to the user's browser in a cookie. |
| 340 | + /** @var Response $response */ |
334 | 341 | $response = service('response'); |
335 | 342 |
|
| 343 | + // Save it to the user's browser in a cookie. |
336 | 344 | // Create the cookie |
337 | 345 | $response->setCookie( |
338 | 346 | setting('Auth.sessionConfig')['rememberCookieName'], |
|
0 commit comments