<?php

namespace App\Http\Middleware;

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

class DummyOAuth
{
    /**
     * Handle an incoming request.
     * Temporary middleware to replace OAuth2 until Passport is configured.
     *
     * @param  Request  $request
     * @param  Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        // For now, just check if user is authenticated via web guard
        if (Auth::check()) {
            return $next($request);
        }

        // Return unauthorized for API requests
        return response()->json(['error' => 'Unauthorized'], 401);
    }
} 