more verbose errors for login and verify

This commit is contained in:
Henry Hiles 2026-03-26 15:53:42 -04:00
commit 0d1f7c1819
No known key found for this signature in database
3 changed files with 12 additions and 12 deletions

View file

@ -153,12 +153,12 @@ class ClientController extends AsyncNotifier<int> {
Future<void> sendMessage(SendMessageRequest request) => Future<void> sendMessage(SendMessageRequest request) =>
_sendCommand("send_message", request.toJson()); _sendCommand("send_message", request.toJson());
Future<bool> verify(String recoveryKey) async { Future<String?> verify(String recoveryKey) async {
try { try {
await _sendCommand("verify", {"recovery_key": recoveryKey}); await _sendCommand("verify", {"recovery_key": recoveryKey});
return true; return null;
} catch (error) { } catch (error) {
return false; return error.toString();
} }
} }
@ -228,12 +228,12 @@ class ClientController extends AsyncNotifier<int> {
}); });
} }
Future<bool> login(LoginRequest login) async { Future<String?> login(LoginRequest login) async {
try { try {
await _sendCommand("login", login.toJson()); await _sendCommand("login", login.toJson());
return true; return null;
} catch (error) { } catch (error) {
return false; return error.toString();
} }
} }

View file

@ -175,7 +175,7 @@ class LoginPage extends HookConsumerWidget {
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
isLoading.value = true; isLoading.value = true;
final succeeded = await client.login( final error = await client.login(
LoginRequest( LoginRequest(
username: username.text, username: username.text,
password: password.text, password: password.text,
@ -183,11 +183,11 @@ class LoginPage extends HookConsumerWidget {
), ),
); );
if (!succeeded && context.mounted) { if (error != null && context.mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
"Login failed. Is your password right?", "Login failed. Is your password right?\nError: $error",
style: TextStyle( style: TextStyle(
color: theme.colorScheme.onErrorContainer, color: theme.colorScheme.onErrorContainer,
), ),

View file

@ -48,12 +48,12 @@ class VerifyPage extends HookConsumerWidget {
isVerifying.value = true; isVerifying.value = true;
final success = await ref final error = await ref
.watch(ClientController.provider.notifier) .watch(ClientController.provider.notifier)
.verify(passphraseController.text); .verify(passphraseController.text);
snackbar.close(); snackbar.close();
if (!success) { if (error != null) {
isVerifying.value = false; isVerifying.value = false;
if (context.mounted) { if (context.mounted) {
scaffoldMessenger.showSnackBar( scaffoldMessenger.showSnackBar(
@ -62,7 +62,7 @@ class VerifyPage extends HookConsumerWidget {
context, context,
).colorScheme.errorContainer, ).colorScheme.errorContainer,
content: Text( content: Text(
"Verification failed. Is your passphrase correct?", "Verification failed. Is your passphrase correct?\nError: $error",
style: TextStyle( style: TextStyle(
color: Theme.of( color: Theme.of(
context, context,