| @@ 74-98 (lines=25) @@ | ||
| 71 | * |
|
| 72 | * @return bool|\Illuminate\Http\RedirectResponse|mixed|string |
|
| 73 | */ |
|
| 74 | public function attempt() |
|
| 75 | { |
|
| 76 | $extensions = $this->extensions->search('anomaly.module.users::security_check.*'); |
|
| 77 | ||
| 78 | /* @var SecurityCheckInterface $extension */ |
|
| 79 | foreach ($extensions as $extension) { |
|
| 80 | ||
| 81 | /* |
|
| 82 | * If the security check does not return |
|
| 83 | * false then we can assume it passed. |
|
| 84 | */ |
|
| 85 | ||
| 86 | $response = $extension->attempt(); |
|
| 87 | ||
| 88 | if ($response === true) { |
|
| 89 | continue; |
|
| 90 | } |
|
| 91 | ||
| 92 | $this->events->fire(new SecurityCheckHasFailed($extension)); |
|
| 93 | ||
| 94 | return $response; |
|
| 95 | } |
|
| 96 | ||
| 97 | return true; |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * Check authorization. |
|
| @@ 106-130 (lines=25) @@ | ||
| 103 | * @param UserInterface $user |
|
| 104 | * @return bool|\Illuminate\Http\RedirectResponse|mixed|string |
|
| 105 | */ |
|
| 106 | public function check(UserInterface $user = null) |
|
| 107 | { |
|
| 108 | $extensions = $this->extensions->search('anomaly.module.users::security_check.*'); |
|
| 109 | ||
| 110 | /* @var SecurityCheckInterface $extension */ |
|
| 111 | foreach ($extensions as $extension) { |
|
| 112 | ||
| 113 | /* |
|
| 114 | * If the security check does not return |
|
| 115 | * false then we can assume it passed. |
|
| 116 | */ |
|
| 117 | ||
| 118 | $response = $extension->check($user); |
|
| 119 | ||
| 120 | if ($response === true) { |
|
| 121 | continue; |
|
| 122 | } |
|
| 123 | ||
| 124 | $this->events->fire(new SecurityCheckHasFailed($extension)); |
|
| 125 | ||
| 126 | return $response; |
|
| 127 | } |
|
| 128 | ||
| 129 | return true; |
|
| 130 | } |
|
| 131 | } |
|
| 132 | ||