more verbose errors for login and verify
This commit is contained in:
parent
4bbf694479
commit
0d1f7c1819
3 changed files with 12 additions and 12 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue