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 CheckUserRestricted
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 ($this->auth->check() && $this->auth->user()->isRestricted()) {
43 return error_popup(osu_trans('errors.no_restricted_access'));
44 }
45
46 return $next($request);
47 }
48}