<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class CheckFirebaseAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
     */
    public function handle(Request $request, Closure $next): Response
    {
        // Periksa apakah ada session auth token yang ada
        if (!session()->has('firebase_auth_checked') || !session()->get('firebase_auth_checked')) {
            // Jika tidak ada, redirect ke halaman login
            return redirect()->route('login');
        }

        return $next($request);
    }
} 