<?php

namespace Modules\Auth\Actions\Fortify;

use Illuminate\Http\JsonResponse;
use Laravel\Fortify\Contracts\LoginResponse as ContractsLoginResponse;
use Modules\Auth\Services\AuthSessionService;

class LoginResponse implements ContractsLoginResponse
{
    public function __construct(
        protected AuthSessionService $authSession,
    ) {}

    public function toResponse($request): JsonResponse
    {
        return $this->authSession->createAuthResponse(
            $request->user(),
            'Login successful'
        );
    }
}
