the browser-facing portion of osu!
at master 1.2 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Http\Middleware; 7 8use Closure; 9use Illuminate\Contracts\Auth\Guard; 10 11class CheckUserBanStatus 12{ 13 /** 14 * The Guard implementation. 15 * 16 * @var Guard 17 */ 18 protected $auth; 19 20 /** 21 * Create a new filter instance. 22 * 23 * @param Guard $auth 24 * 25 * @return void 26 */ 27 public function __construct(Guard $auth) 28 { 29 $this->auth = $auth; 30 } 31 32 /** 33 * Handle an incoming request. 34 * 35 * @param \Illuminate\Http\Request $request 36 * @param \Closure $next 37 * 38 * @return mixed 39 */ 40 public function handle($request, Closure $next) 41 { 42 if ( 43 $this->auth->check() 44 && ($this->auth->user()->isBanned() || $this->auth->user()->isLoginBlocked()) 45 ) { 46 logout(); 47 48 if (is_api_request()) { 49 abort(403, osu_trans('users.disabled.title')); 50 } else { 51 return ujs_redirect(route('users.disabled')); 52 } 53 } 54 55 return $next($request); 56 } 57}