<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class AI_Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string
     */
    public  function  handle($request, Closure $next, ...$guards)
    {
        $request->session()->all();
        $ailock= $request->session()->get('AI_lock');
        if($ailock==="defaul"){
            //return redirect('User/insert');
            //return redirect()->action("UserController@index_insert");
           //return parent::handle($request, $next, $guards); // TODO: Change the autogenerated stub
              return $next($request);
        }else{
            return redirect('/');
        }
    }
}
