|
3 | 3 | namespace CodeIgniter\Shield\Models; |
4 | 4 |
|
5 | 5 | use CodeIgniter\I18n\Time; |
6 | | -use CodeIgniter\Model; |
7 | 6 | use CodeIgniter\Shield\Entities\Login; |
8 | 7 | use Exception; |
9 | 8 | use Faker\Generator; |
10 | 9 |
|
11 | | -class TokenLoginModel extends Model |
| 10 | +class TokenLoginModel extends LoginModel |
12 | 11 | { |
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'; |
59 | 13 |
|
60 | 14 | /** |
61 | 15 | * Generate a fake login for testing |
|
0 commit comments