Skip to content

Commit 4d4d9b8

Browse files
committed
feat: record Access Token login in auth_token_logins table
1 parent 838ca9a commit 4d4d9b8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Authentication/Authenticators/AccessTokens.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use CodeIgniter\Shield\Authentication\AuthenticationException;
88
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
99
use CodeIgniter\Shield\Entities\User;
10-
use CodeIgniter\Shield\Models\LoginModel;
10+
use CodeIgniter\Shield\Models\TokenLoginModel;
1111
use CodeIgniter\Shield\Models\UserIdentityModel;
1212
use CodeIgniter\Shield\Models\UserModel;
1313
use CodeIgniter\Shield\Result;
@@ -21,15 +21,15 @@ class AccessTokens implements AuthenticatorInterface
2121
protected UserModel $provider;
2222

2323
protected ?User $user = null;
24-
protected LoginModel $loginModel;
24+
protected TokenLoginModel $loginModel;
2525

2626
public function __construct(UserModel $provider)
2727
{
2828
helper('session');
2929

3030
$this->provider = $provider;
3131

32-
$this->loginModel = model(LoginModel::class); // @phpstan-ignore-line
32+
$this->loginModel = model(TokenLoginModel::class); // @phpstan-ignore-line
3333
}
3434

3535
/**

tests/Authentication/AccessTokenAuthenticatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function testAttemptCannotFindUser()
168168
$this->assertSame(lang('Auth.badToken'), $result->reason());
169169

170170
// A login attempt should have always been recorded
171-
$this->seeInDatabase('auth_logins', [
171+
$this->seeInDatabase('auth_token_logins', [
172172
'identifier' => 'token: abc123',
173173
'success' => 0,
174174
]);
@@ -195,7 +195,7 @@ public function testAttemptSuccess()
195195
$this->assertSame($token->token, $foundUser->currentAccessToken()->token);
196196

197197
// A login attempt should have been recorded
198-
$this->seeInDatabase('auth_logins', [
198+
$this->seeInDatabase('auth_token_logins', [
199199
'identifier' => 'token: ' . $token->raw_token,
200200
'success' => 1,
201201
]);

0 commit comments

Comments
 (0)