Skip to content

Commit 497161d

Browse files
authored
authenticate user while login (#630)
* fix: authenticate user while login * Fix styling --------- Co-authored-by: binaryk <binaryk@users.noreply.github.com>
1 parent 8b3a268 commit 497161d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/Exceptions/Solutions/OpenAiSolution.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ public function __construct(protected Throwable $throwable)
1818
now()->addHour(),
1919
fn () => OpenAI::chat()->create([
2020
'model' => config('restify.ai_solutions.model', 'gpt-4.1-mini'),
21-
'messages' =>
21+
'messages' => [
2222
[
23-
[
24-
'role' => 'user',
25-
'content' => $this->generatePrompt($this->throwable),
26-
],
27-
[
28-
'role' => 'system',
29-
'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.',
30-
],
23+
'role' => 'user',
24+
'content' => $this->generatePrompt($this->throwable),
3125
],
26+
[
27+
'role' => 'system',
28+
'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.',
29+
],
30+
],
3231
'max_tokens' => config('restify.ai_solutions.max_tokens', 1000),
3332
'temperature' => 0,
3433
])->choices[0]->message->content

src/Http/Controllers/Auth/LoginController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Binaryk\LaravelRestify\Tests\Fixtures\User\User;
66
use Illuminate\Http\Request;
77
use Illuminate\Routing\Controller;
8+
use Illuminate\Support\Facades\Auth;
89
use Illuminate\Support\Facades\Hash;
910

1011
class LoginController extends Controller
@@ -27,6 +28,8 @@ public function __invoke(Request $request)
2728
abort(401, 'Invalid credentials.');
2829
}
2930

31+
Auth::login($user);
32+
3033
return rest($user)->indexMeta([
3134
'token' => $user->createToken('login')->plainTextToken,
3235
]);

0 commit comments

Comments
 (0)