1 | <?php |
||
2 | |||
3 | namespace AloiaCms\Auth; |
||
4 | |||
5 | use AloiaCms\Models\Contracts\ModelInterface; |
||
6 | use AloiaCms\Models\Model; |
||
7 | use Illuminate\Contracts\Auth\Authenticatable; |
||
8 | |||
9 | class User extends Model implements Authenticatable |
||
10 | { |
||
11 | protected $folder = 'users'; |
||
12 | |||
13 | protected $required_fields = [ |
||
14 | 'identifier' |
||
15 | ]; |
||
16 | |||
17 | public function findById(string $file_name): ModelInterface |
||
18 | { |
||
19 | $instance = new static(); |
||
20 | |||
21 | $instance->setFileName($file_name); |
||
22 | $instance->set('identifier', $file_name); |
||
23 | |||
24 | return $instance; |
||
25 | } |
||
26 | |||
27 | public static function find(string $file_name): ModelInterface |
||
28 | { |
||
29 | $instance = new static(); |
||
30 | $instance->setFileName($file_name); |
||
31 | $instance->set('identifier', $file_name); |
||
32 | |||
33 | return $instance; |
||
34 | } |
||
35 | |||
36 | public function getAuthIdentifierName() |
||
37 | { |
||
38 | return 'identifier'; |
||
39 | } |
||
40 | |||
41 | public function getAuthIdentifier() |
||
42 | { |
||
43 | return $this->filename(); |
||
44 | } |
||
45 | |||
46 | public function getAuthPassword() |
||
47 | { |
||
48 | return $this->get('password'); |
||
49 | } |
||
50 | |||
51 | public function getRememberToken() |
||
52 | { |
||
53 | return $this->get('remember_token'); |
||
54 | } |
||
55 | |||
56 | public function setRememberToken($value) |
||
57 | { |
||
58 | return $this->set('remember_token', $value); |
||
0 ignored issues
–
show
|
|||
59 | } |
||
60 | |||
61 | public function getRememberTokenName() |
||
62 | { |
||
63 | return 'remember_token'; |
||
64 | } |
||
65 | |||
66 | public function getAuthPasswordName() |
||
67 | { |
||
68 | return 'password'; |
||
69 | } |
||
70 | } |
||
71 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: