dev-think-one /
laravel-release-protection
| 1 | <?php |
||||
| 2 | |||||
| 3 | |||||
| 4 | namespace ReleaseProtection\Http\Middleware; |
||||
| 5 | |||||
| 6 | use Auth; |
||||
| 7 | use Closure; |
||||
| 8 | |||||
| 9 | class TestersEmailMiddleware |
||||
| 10 | { |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * Handle an incoming request. |
||||
| 14 | * |
||||
| 15 | * @param \Illuminate\Http\Request $request |
||||
| 16 | * @param Closure $next |
||||
| 17 | * @param string $guard |
||||
| 18 | * |
||||
| 19 | * @return mixed |
||||
| 20 | */ |
||||
| 21 | 7 | public function handle($request, Closure $next, $guard = null) |
|||
| 22 | { |
||||
| 23 | 7 | if (app()->environment(config('release-protection.email.envs.' . $guard, config('release-protection.email.envs.default')))) { |
|||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 24 | 7 | $user = Auth::guard($guard)->user(); |
|||
| 25 | 7 | if (!$user) { |
|||
| 26 | 2 | abort( |
|||
| 27 | 2 | config('release-protection.email.status.not_logged.' . $guard, config('release-protection.email.status.not_logged.default')), |
|||
| 28 | 2 | __(config('release-protection.email.msg.not_logged.' . $guard, config('release-protection.email.msg.not_logged.default'))) |
|||
|
0 ignored issues
–
show
It seems like
__(config('release-prote....not_logged.default'))) can also be of type array; however, parameter $message of abort() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 29 | 2 | ); |
|||
| 30 | } |
||||
| 31 | |||||
| 32 | 5 | $allowEmails = config('release-protection.email.emails.' . $guard, config('release-protection.email.emails.default')); |
|||
| 33 | 5 | $allowEmails = array_map(fn ($e) => trim(strtolower($e)), $allowEmails); |
|||
| 34 | |||||
| 35 | 5 | if (!$user->email || !in_array(strtolower($user->email), $allowEmails)) { |
|||
|
0 ignored issues
–
show
|
|||||
| 36 | 3 | abort( |
|||
| 37 | 3 | config('release-protection.email.status.restricted.' . $guard, config('release-protection.email.status.restricted.default')), |
|||
| 38 | 3 | __(config('release-protection.email.msg.restricted.' . $guard, config('release-protection.email.msg.restricted.default'))) |
|||
| 39 | 3 | ); |
|||
| 40 | } |
||||
| 41 | } |
||||
| 42 | |||||
| 43 | 2 | return $next($request); |
|||
| 44 | } |
||||
| 45 | } |
||||
| 46 |