| Total Complexity | 6 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 13 | class Authenticate extends Middleware |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * The Guard implementation. |
||
| 17 | * |
||
| 18 | * @var Guard |
||
| 19 | */ |
||
| 20 | protected $auth; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Create a new filter instance. |
||
| 24 | * |
||
| 25 | * @param Guard $auth |
||
| 26 | * |
||
| 27 | * @return void |
||
| 28 | */ |
||
| 29 | public function __construct(Guard $auth) |
||
| 30 | { |
||
| 31 | $this->auth = $auth; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Get the path the user should be redirected to when they are not authenticated. |
||
| 36 | * |
||
| 37 | * @param \Illuminate\Http\Request $request |
||
| 38 | * @return string|null |
||
| 39 | */ |
||
| 40 | protected function redirectTo($request) |
||
| 41 | { |
||
| 42 | if (! $request->expectsJson()) { |
||
| 43 | return route('login'); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Handle an incoming request. |
||
| 49 | * |
||
| 50 | * @param \Illuminate\Http\Request $request |
||
| 51 | * @param \Closure $next |
||
| 52 | * |
||
| 53 | * @return mixed |
||
| 54 | */ |
||
| 55 | public function handle($request, Closure $next) |
||
| 56 | { |
||
| 57 | if (! $this->auth->check()) { |
||
| 58 | return redirect()->to('/login') |
||
| 59 | ->with('status', 'success') |
||
| 60 | ->with('message', 'Please login.'); |
||
| 61 | } |
||
| 62 | |||
| 63 | return $next($request); |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Log a termination. |
||
| 68 | * @param \Illuminate\Http\Request $request |
||
| 69 | * @param $response |
||
| 70 | * |
||
| 71 | * @return void |
||
| 72 | */ |
||
| 73 | public function terminate($request, $response) |
||
| 77 | // Log::info('Authenticate middleware was used: '.$currentRoute.'. ', [$user]); |
||
| 78 | } |
||
| 79 | } |
||
| 80 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.