Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class CurrentPin implements Rule |
||
10 | { |
||
11 | |||
12 | private bool $defaultPin = false; |
||
13 | private bool $allowDefaultPin = false; |
||
14 | /** |
||
15 | * Create a new rule instance. |
||
16 | * |
||
17 | * @return void |
||
18 | */ |
||
19 | public function __construct(bool $allowDefaultPin = false) |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Determine if the validation rule passes. |
||
27 | * |
||
28 | * @param string $attribute |
||
29 | * @param mixed $value |
||
30 | * @return bool |
||
31 | */ |
||
32 | public function passes($attribute, $value) |
||
33 | { |
||
34 | if (Auth::guard(config('requirepin.auth_guard', 'web'))->user()->default_pin && !$this->allowDefaultPin) { |
||
|
|||
35 | $this->defaultPin = true; |
||
36 | |||
37 | return false; |
||
38 | } |
||
39 | |||
40 | return Hash::check($value, Auth::guard(config('requirepin.auth_guard', 'web'))->user()->pin); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Get the validation error message. |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | public function message() |
||
55 | } |
||
56 | } |
||
57 |