diff --git a/app/Livewire/Onboarding.php b/app/Livewire/Onboarding.php index f6ab9de..2c738c8 100644 --- a/app/Livewire/Onboarding.php +++ b/app/Livewire/Onboarding.php @@ -183,13 +183,22 @@ public function createPlatformAccount(): void $this->nextStep(); } catch (\App\Exceptions\PlatformAuthException $e) { - if (str_contains($e->getMessage(), 'Rate limited by')) { - $this->formErrors['general'] = $e->getMessage(); + $message = $e->getMessage(); + if (str_contains($message, 'Rate limited by')) { + $this->formErrors['general'] = $message; + } elseif (str_contains($message, 'Connection failed')) { + $this->formErrors['general'] = 'Unable to connect to the Lemmy instance. Please check the URL and try again.'; } else { $this->formErrors['general'] = 'Invalid username or password. Please check your credentials and try again.'; } } catch (\Exception $e) { - $this->formErrors['general'] = 'Unable to connect to the Lemmy instance. Please check the URL and try again.'; + logger()->error('Lemmy platform account creation failed', [ + 'instance_url' => $fullInstanceUrl, + 'username' => $this->username, + 'error' => $e->getMessage(), + 'class' => get_class($e), + ]); + $this->formErrors['general'] = 'An error occurred while setting up your account. Please try again.'; } finally { $this->isLoading = false; } diff --git a/app/Modules/Lemmy/Services/LemmyApiService.php b/app/Modules/Lemmy/Services/LemmyApiService.php index 3329703..d0ebb55 100644 --- a/app/Modules/Lemmy/Services/LemmyApiService.php +++ b/app/Modules/Lemmy/Services/LemmyApiService.php @@ -63,6 +63,11 @@ public function login(string $username, string $password): ?string $data = $response->json(); return $data['jwt'] ?? null; } catch (Exception $e) { + // Re-throw rate limit exceptions immediately + if (str_contains($e->getMessage(), 'Rate limited')) { + throw $e; + } + logger()->error('Lemmy login exception', ['error' => $e->getMessage(), 'scheme' => $scheme]); // If this was the first attempt and HTTPS, try HTTP next if ($idx === 0 && in_array('http', $schemesToTry, true)) { diff --git a/database/migrations/2024_01_01_000003_create_platforms.php b/database/migrations/2024_01_01_000003_create_platforms.php index 9a074a9..9b7f7af 100644 --- a/database/migrations/2024_01_01_000003_create_platforms.php +++ b/database/migrations/2024_01_01_000003_create_platforms.php @@ -27,7 +27,7 @@ public function up(): void $table->enum('platform', ['lemmy']); $table->string('instance_url'); $table->string('username'); - $table->string('password'); + $table->text('password'); $table->json('settings')->nullable(); $table->boolean('is_active')->default(false); $table->timestamp('last_tested_at')->nullable();