Example #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $player = $this->router->getCurrentRoute()->getParameter('player');
     if (!$player or $player->isDeleted()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             throw new NotDeletedPlayerException();
         }
     }
     return $next($request);
 }
Example #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $redirect = '/')
 {
     $world = $this->router->getCurrentRoute()->getParameter('world');
     if (worlds()->count() > 1 and !$world) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect($redirect);
         }
     }
     return $next($request);
 }
Example #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $player = $this->router->getCurrentRoute()->getParameter('player');
     $player->load('account');
     if (!$this->auth->check() or !$player or $this->auth->id() !== $player->account->id()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             throw new DifferentAccountPlayerException();
         }
     }
     return $next($request);
 }