<?php

namespace App\Http\Middleware;

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

class EnsureMeetupSuperAdmin
{
    public function handle(Request $request, Closure $next): Response
    {
        if (! $request->session()->get('meetup_super_authenticated')) {
            return redirect()->route('mexco.super.login')
                ->with('error', 'Please sign in as Super Admin.');
        }

        return $next($request);
    }
}
