From 2b1853b5e35c37ec85cca1f280cac14184eed363 Mon Sep 17 00:00:00 2001 From: olorin99 Date: Mon, 27 Apr 2026 14:56:10 +1000 Subject: [PATCH] Truncate entered password to match lemmy/piefed limits. --- lib/src/controller/controller.dart | 5 ++++- lib/src/screens/settings/login_confirm.dart | 6 ++++-- lib/src/widgets/password_editor.dart | 9 ++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/src/controller/controller.dart b/lib/src/controller/controller.dart index acdc54f2..0d48a5d4 100644 --- a/lib/src/controller/controller.dart +++ b/lib/src/controller/controller.dart @@ -473,7 +473,10 @@ class AppController with ChangeNotifier { ServerSoftware.piefed => 'username', ServerSoftware.mbin => throw UnreachableError(), }: username, - 'password': password, + 'password': password?.substring( + 0, + software == ServerSoftware.lemmy ? 60 : 128, + ), if (software == ServerSoftware.lemmy) 'totp_2fa_token': totp, }), ); diff --git a/lib/src/screens/settings/login_confirm.dart b/lib/src/screens/settings/login_confirm.dart index 6336c20a..5f37602c 100644 --- a/lib/src/screens/settings/login_confirm.dart +++ b/lib/src/screens/settings/login_confirm.dart @@ -52,6 +52,7 @@ class _LoginConfirmScreenState extends State { padding: const EdgeInsets.all(16), child: AutofillGroup( child: Column( + spacing: 12, children: [ TextEditor( _usernameEmailTextController, @@ -63,13 +64,14 @@ class _LoginConfirmScreenState extends State { AutofillHints.email, ], ), - const SizedBox(height: 12), PasswordEditor( _passwordTextController, onChanged: (_) => setState(() {}), + maxLength: widget.software == ServerSoftware.lemmy + ? 60 + : 128, ), if (widget.software == ServerSoftware.lemmy) ...[ - const SizedBox(height: 12), TextEditor( _totpTokenTextController, label: l(context).totpToken, diff --git a/lib/src/widgets/password_editor.dart b/lib/src/widgets/password_editor.dart index f803d473..14411f8a 100644 --- a/lib/src/widgets/password_editor.dart +++ b/lib/src/widgets/password_editor.dart @@ -2,10 +2,16 @@ import 'package:flutter/material.dart'; import 'package:interstellar/src/utils/utils.dart'; class PasswordEditor extends StatefulWidget { - const PasswordEditor(this.controller, {this.onChanged, super.key}); + const PasswordEditor( + this.controller, { + this.onChanged, + this.maxLength, + super.key, + }); final TextEditingController controller; final void Function(String)? onChanged; + final int? maxLength; @override State createState() => _PasswordEditorState(); @@ -34,6 +40,7 @@ class _PasswordEditorState extends State { onChanged: widget.onChanged, autofillHints: const [AutofillHints.password], obscureText: obscureText, + maxLength: widget.maxLength, ); } }