Files
nl-admin-api/app/Http/Middleware/GuestMiddleware.php

46 lines
761 B
PHP
Raw Normal View History

2014-10-06 15:25:53 -05:00
<?php namespace App\Http\Middleware;
2014-09-22 20:22:17 -05:00
2014-10-06 15:25:53 -05:00
use Closure;
2014-10-12 20:46:47 -05:00
use Illuminate\Contracts\Auth\Guard;
2014-09-23 08:31:57 -05:00
use Illuminate\Http\RedirectResponse;
2014-10-06 15:25:53 -05:00
use Illuminate\Contracts\Routing\Middleware;
2014-09-22 20:22:17 -05:00
2014-10-06 15:25:53 -05:00
class GuestMiddleware implements Middleware {
2014-09-22 20:22:17 -05:00
/**
2014-10-12 20:46:47 -05:00
* The Guard implementation.
2014-09-22 20:22:17 -05:00
*
2014-10-12 20:46:47 -05:00
* @var Guard
2014-09-22 20:22:17 -05:00
*/
protected $auth;
/**
* Create a new filter instance.
*
2014-10-12 20:46:47 -05:00
* @param Guard $auth
2014-09-22 20:22:17 -05:00
* @return void
*/
2014-10-12 20:46:47 -05:00
public function __construct(Guard $auth)
2014-09-22 20:22:17 -05:00
{
$this->auth = $auth;
}
/**
2014-10-06 15:25:53 -05:00
* Handle an incoming request.
2014-09-22 20:22:17 -05:00
*
2014-10-06 15:46:34 -05:00
* @param \Illuminate\Http\Request $request
2014-10-06 15:25:53 -05:00
* @param \Closure $next
2014-10-06 15:46:34 -05:00
* @return mixed
2014-09-22 20:22:17 -05:00
*/
2014-10-06 15:25:53 -05:00
public function handle($request, Closure $next)
2014-09-22 20:22:17 -05:00
{
if ($this->auth->check())
{
2014-09-23 08:31:57 -05:00
return new RedirectResponse(url('/'));
2014-09-22 20:22:17 -05:00
}
2014-10-06 15:25:53 -05:00
return $next($request);
2014-09-22 20:22:17 -05:00
}
2014-09-21 20:31:42 +01:00
}