Skip to content

Commit c5c24e0

Browse files
committed
refactor: TokenLoginModel
To fix phpcpd error.
1 parent 4d4d9b8 commit c5c24e0

File tree

1 file changed

+2
-48
lines changed

1 file changed

+2
-48
lines changed

src/Models/TokenLoginModel.php

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,13 @@
33
namespace CodeIgniter\Shield\Models;
44

55
use CodeIgniter\I18n\Time;
6-
use CodeIgniter\Model;
76
use CodeIgniter\Shield\Entities\Login;
87
use Exception;
98
use Faker\Generator;
109

11-
class TokenLoginModel extends Model
10+
class TokenLoginModel extends LoginModel
1211
{
13-
use CheckQueryReturnTrait;
14-
15-
protected $table = 'auth_token_logins';
16-
protected $primaryKey = 'id';
17-
protected $returnType = Login::class;
18-
protected $useSoftDeletes = false;
19-
protected $allowedFields = [
20-
'ip_address',
21-
'user_agent',
22-
'identifier',
23-
'user_id',
24-
'date',
25-
'success',
26-
];
27-
protected $useTimestamps = false;
28-
protected $validationRules = [
29-
'ip_address' => 'required',
30-
'identifier' => 'required',
31-
'user_agent' => 'permit_empty|string',
32-
'user_id' => 'permit_empty|integer',
33-
'date' => 'required|valid_date',
34-
];
35-
protected $validationMessages = [];
36-
protected $skipValidation = false;
37-
38-
/**
39-
* @param int|string|null $userId
40-
*/
41-
public function recordLoginAttempt(
42-
string $identifier,
43-
bool $success,
44-
?string $ipAddress = null,
45-
?string $userAgent = null,
46-
$userId = null
47-
): void {
48-
$return = $this->insert([
49-
'ip_address' => $ipAddress,
50-
'user_agent' => $userAgent,
51-
'identifier' => $identifier,
52-
'user_id' => $userId,
53-
'date' => date('Y-m-d H:i:s'),
54-
'success' => (int) $success,
55-
]);
56-
57-
$this->checkQueryReturn($return);
58-
}
12+
protected $table = 'auth_token_logins';
5913

6014
/**
6115
* Generate a fake login for testing

0 commit comments

Comments
 (0)