示例#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);
 }
示例#2
0
文件: Exist.php 项目: apolune/worlds
 /**
  * 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);
 }
示例#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);
 }