improved error messages

This commit is contained in:
Adam Velebil 2022-08-04 08:24:12 +02:00
parent 4e7ad56634
commit 2cca27adf1
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
2 changed files with 16 additions and 4 deletions

View File

@ -44,6 +44,11 @@ enum Application {
} }
Availability getAvailability(YubiKeyData data) { Availability getAvailability(YubiKeyData data) {
if (data.info.isSky && this != Application.fido) {
return Availability.unsupported;
}
if (this == Application.management) { if (this == Application.management) {
final version = data.info.version; final version = data.info.version;
final available = (version.major > 4 || // YK5 and up final available = (version.major > 4 || // YK5 and up

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
@ -34,15 +36,20 @@ class MainPage extends ConsumerWidget {
final deviceNode = ref.watch(currentDeviceProvider); final deviceNode = ref.watch(currentDeviceProvider);
if (deviceNode == null) { if (deviceNode == null) {
return const MessagePage(message: 'Insert your YubiKey'); return MessagePage(message: Platform.isAndroid ? 'Insert or tap your YubiKey' : 'Insert your YubiKey');
} else { } else {
return ref.watch(currentDeviceDataProvider).when( return ref.watch(currentDeviceDataProvider).when(
data: (data) { data: (data) {
final app = ref.watch(currentAppProvider); final app = ref.watch(currentAppProvider);
if (app.getAvailability(data) != Availability.enabled) { if (app.getAvailability(data) == Availability.unsupported) {
return const MessagePage( return MessagePage(
header: 'Application not supported',
message: 'The used YubiKey does not support \'${app.name}\' application',
);
} else if (app.getAvailability(data) != Availability.enabled) {
return MessagePage(
header: 'Application disabled', header: 'Application disabled',
message: 'Enable the application on your YubiKey to access', message: 'Enable the \'${app.name}\' application on your YubiKey to access',
); );
} }