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) =>
_sendCommand("send_message", request.toJson());
Future<bool> verify(String recoveryKey) async {
Future<String?> verify(String recoveryKey) async {
try {
await _sendCommand("verify", {"recovery_key": recoveryKey});
return true;
return null;
} 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 {
await _sendCommand("login", login.toJson());
return true;
return null;
} catch (error) {
return false;
return error.toString();
}
}

View file

@ -175,7 +175,7 @@ class LoginPage extends HookConsumerWidget {
ElevatedButton(
onPressed: () async {
isLoading.value = true;
final succeeded = await client.login(
final error = await client.login(
LoginRequest(
username: username.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(
SnackBar(
content: Text(
"Login failed. Is your password right?",
"Login failed. Is your password right?\nError: $error",
style: TextStyle(
color: theme.colorScheme.onErrorContainer,
),

View file

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