diff --git a/app/Livewire/LoginForm.php b/app/Livewire/LoginForm.php
index 9e9f343..3954753 100644
--- a/app/Livewire/LoginForm.php
+++ b/app/Livewire/LoginForm.php
@@ -3,23 +3,54 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
class LoginForm extends Component
{
public $username, $password;
+
+ public function submit()
+ {
+ $this->validate([
+ 'username' => 'required|string',
+ 'password' => 'required|string',
+ ]);
+
+ try {
+ $response = Http::post(env('BACKEND_API_URL') . '/api/login_password', [
+ 'username' => $this->username,
+ 'password' => $this->password,
+ ]);
+
+ if ($response->successful()) {
+ $json = $response->json();
+
+ if ($json['code'] === 200) {
+ // Store UUID in session if needed
+ Session::put('admin_uuid', $json['data']['admin_uuid'] ?? null);
+
+ // Redirect if user must change password
+ if (!empty($json['data']['prompt_password'])) {
+ return redirect('/api/login_changePassword');
+ }
+
+ // Redirect to profile after successful login
+ return redirect('/main/profile');
+ } else {
+ $this->addError('username', $json['message'] ?? 'Login failed.');
+ }
+ } else {
+ $this->addError('username', 'Login request failed. Please try again.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('username', 'An error occurred: ' . $e->getMessage());
+ }
+ }
public function render()
{
return view('livewire.auth.login-form'); // This will point to the resource/views/livewire/auth/login-form.blade.php component
}
- public function submit()
- {
- // Logic for login
- }
-
- public function forgotUsername()
- {
- // Logic for forgot username
- }
}
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index aa15443..1f91032 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -64,4 +64,5 @@ volumes:
networks:
app_network:
- driver: bridge
\ No newline at end of file
+ driver: bridge
+ external: true
\ No newline at end of file
diff --git a/resources/views/livewire/auth/login-form.blade.php b/resources/views/livewire/auth/login-form.blade.php
index 1a51f97..ea55f25 100644
--- a/resources/views/livewire/auth/login-form.blade.php
+++ b/resources/views/livewire/auth/login-form.blade.php
@@ -25,8 +25,9 @@
Forgot Username
-
- Log in
+
+
+