From c172435672368a6fe0adab62bf6500da3e5c42ce Mon Sep 17 00:00:00 2001 From: Eduard Lupacescu Date: Mon, 26 May 2025 21:24:43 +0300 Subject: [PATCH 1/2] fix: authenticate user while login --- src/Http/Controllers/Auth/LoginController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Http/Controllers/Auth/LoginController.php b/src/Http/Controllers/Auth/LoginController.php index 26a1c6c15..d506bb0ed 100644 --- a/src/Http/Controllers/Auth/LoginController.php +++ b/src/Http/Controllers/Auth/LoginController.php @@ -5,6 +5,7 @@ use Binaryk\LaravelRestify\Tests\Fixtures\User\User; use Illuminate\Http\Request; use Illuminate\Routing\Controller; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; class LoginController extends Controller @@ -27,6 +28,8 @@ public function __invoke(Request $request) abort(401, 'Invalid credentials.'); } + Auth::login($user); + return rest($user)->indexMeta([ 'token' => $user->createToken('login')->plainTextToken, ]); From 16171114a907740efbe42acc5141149f51c75635 Mon Sep 17 00:00:00 2001 From: binaryk Date: Mon, 26 May 2025 18:25:05 +0000 Subject: [PATCH 2/2] Fix styling --- src/Exceptions/Solutions/OpenAiSolution.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Exceptions/Solutions/OpenAiSolution.php b/src/Exceptions/Solutions/OpenAiSolution.php index 0b913c727..24af2986a 100644 --- a/src/Exceptions/Solutions/OpenAiSolution.php +++ b/src/Exceptions/Solutions/OpenAiSolution.php @@ -18,17 +18,16 @@ public function __construct(protected Throwable $throwable) now()->addHour(), fn () => OpenAI::chat()->create([ 'model' => config('restify.ai_solutions.model', 'gpt-4.1-mini'), - 'messages' => + 'messages' => [ [ - [ - 'role' => 'user', - 'content' => $this->generatePrompt($this->throwable), - ], - [ - 'role' => 'system', - 'content' => 'Provide a concise solution to the problem described, tailored for a Laravel application using the Restify framework. Avoid explanations, examples, or code snippets. Respond with only the direct answer.', - ], + 'role' => 'user', + 'content' => $this->generatePrompt($this->throwable), ], + [ + 'role' => 'system', + 'content' => 'Provide a concise solution to the problem described, tailored for a Laravel application using the Restify framework. Avoid explanations, examples, or code snippets. Respond with only the direct answer.', + ], + ], 'max_tokens' => config('restify.ai_solutions.max_tokens', 1000), 'temperature' => 0, ])->choices[0]->message->content