<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;

class CheckAppCode
{
    public function handle(Request $request, Closure $next, $appName)
    {
        // HAPUS TANDA // DI BAWAH INI UNTUK DEBUG
        //dd(session()->all()); 

        if (!session()->has($appName . '_verified')) {
            return redirect()->route('app.gate', ['app' => $appName]);
        }

        return $next($request);
    }
}