• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / shield / 14163805301

31 Mar 2025 04:02AM UTC coverage: 92.761% (+0.002%) from 92.759%
14163805301

Pull #1263

github

web-flow
Merge d74c09931 into 568a1308b
Pull Request #1263: refactor: Ensure `findById` returns `null` instead of an array when ID is null

2 of 2 new or added lines in 1 file covered. (100.0%)

2832 of 3053 relevant lines covered (92.76%)

149.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Entities/UserIdentity.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter Shield.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Shield\Entities;
15

16
use CodeIgniter\Entity\Entity;
17
use CodeIgniter\I18n\Time;
18
use CodeIgniter\Shield\Authentication\Passwords;
19

20
/**
21
 * Class UserIdentity
22
 *
23
 * Represents a single set of user identity credentials.
24
 * For the base Shield system, this would be one of the following:
25
 *  - password
26
 *  - reset hash
27
 *  - access token
28
 *
29
 * This can also be used to store credentials for social logins,
30
 * OAUTH or JWT tokens, etc. A user can have multiple of each,
31
 * though a Authenticator may want to enforce only one exists for that
32
 * user, like a password.
33
 *
34
 * @property string|Time|null $last_used_at
35
 * @property string|null      $secret
36
 * @property string|null      $secret2
37
 */
38
class UserIdentity extends Entity
39
{
40
    /**
41
     * @var array<string, string>
42
     */
43
    protected $casts = [
44
        'id'          => '?integer',
45
        'force_reset' => 'int-bool',
46
    ];
47

48
    /**
49
     * @var list<string>
50
     */
51
    protected $dates = [
52
        'expires',
53
        'last_used_at',
54
    ];
55

56
    /**
57
     * Uses password-strength hashing to hash
58
     * a given value for the 'secret'.
59
     */
60
    public function hashSecret(string $value): UserIdentity
61
    {
62
        /** @var Passwords $passwords */
63
        $passwords = service('passwords');
×
64

65
        $this->attributes['secret'] = $passwords->hash($value);
×
66

67
        return $this;
×
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc