| Conditions | 6 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 46 | public function handle($request, Closure $next) |
||
| 47 | { |
||
| 48 | $user = $this->auth->user(); |
||
| 49 | |||
| 50 | if ($user && $user instanceof BannableContract && $user->isBanned()) { |
||
| 51 | $redirectUrl = config('ban.redirect_url', null); |
||
| 52 | $errors = [ |
||
| 53 | 'login' => 'This account is blocked.', |
||
| 54 | ]; |
||
| 55 | |||
| 56 | $responseCode = $request->header('X-Inertia') ? 303 : 302; |
||
| 57 | if ($redirectUrl === null) { |
||
| 58 | return redirect()->back($responseCode)->withInput()->withErrors($errors); |
||
| 59 | } else { |
||
| 60 | return redirect($redirectUrl, $responseCode)->withInput()->withErrors($errors); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | return $next($request); |
||
| 65 | } |
||
| 67 |