<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use App\Http\Controllers\Controller;

class AuthenticatedSessionController extends Controller
{
    public function login(Request $request)
    {

dd([
    'lms_api' => config('services.lms.api'),
]);


        $request->validate([
            'identifier' => 'required|string',
            'password'   => 'required|string',
        ]);

        $response = Http::post(
            config('services.lms.api') . '/login',
            $request->only('identifier', 'password')
        );

        if ($response->failed()) {
            return response()->json($response->json(), 422);
        }

        return response()->json($response->json());
    }
}
