| Conditions | 5 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 17 | public function handle($request, Closure $next) |
||
| 18 | { |
||
| 19 | //check login |
||
| 20 | if(!Auth::check()){ |
||
| 21 | return $next($request); |
||
| 22 | } |
||
| 23 | $user = Auth::user(); |
||
| 24 | $banned = $user->banneds()->orderBy('removed_at', 'desc')->first(); |
||
| 25 | //check if there are any banned records |
||
| 26 | if(empty($banned)) { |
||
| 27 | return $next($request); |
||
| 28 | } |
||
| 29 | //check the time of the last record |
||
| 30 | if(strtotime($banned->removed_at) <= time()){ |
||
| 31 | return $next($request); |
||
| 32 | } |
||
| 33 | //return error page |
||
| 34 | if($request->method() == 'GET'){ |
||
| 35 | return response()->view('errors.451',[ |
||
| 36 | 'description' => "Your account is currently blocked and will remain so until {$banned->removed_at}. Here's why: {$banned->reason}", |
||
| 37 | ]); |
||
| 38 | }else{ |
||
| 39 | return response()->json([ |
||
| 40 | 'ret' => 451, |
||
| 41 | 'desc' => 'Unavailable For Legal Reasons', |
||
| 42 | 'data' => "Your account is currently blocked and will remain so until {$banned->removed_at}. Here's why: {$banned->reason}" |
||
| 43 | ]); |
||
| 47 |