From 2cca27adf1e576f2963b40b5cdc8b66ad03c992c Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Thu, 4 Aug 2022 08:24:12 +0200 Subject: [PATCH] improved error messages --- lib/app/models.dart | 5 +++++ lib/app/views/main_page.dart | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/app/models.dart b/lib/app/models.dart index ea92447c..7e972c1b 100755 --- a/lib/app/models.dart +++ b/lib/app/models.dart @@ -44,6 +44,11 @@ enum Application { } Availability getAvailability(YubiKeyData data) { + + if (data.info.isSky && this != Application.fido) { + return Availability.unsupported; + } + if (this == Application.management) { final version = data.info.version; final available = (version.major > 4 || // YK5 and up diff --git a/lib/app/views/main_page.dart b/lib/app/views/main_page.dart index 557cf9af..1aa07e1c 100755 --- a/lib/app/views/main_page.dart +++ b/lib/app/views/main_page.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -34,15 +36,20 @@ class MainPage extends ConsumerWidget { final deviceNode = ref.watch(currentDeviceProvider); if (deviceNode == null) { - return const MessagePage(message: 'Insert your YubiKey'); + return MessagePage(message: Platform.isAndroid ? 'Insert or tap your YubiKey' : 'Insert your YubiKey'); } else { return ref.watch(currentDeviceDataProvider).when( data: (data) { final app = ref.watch(currentAppProvider); - if (app.getAvailability(data) != Availability.enabled) { - return const MessagePage( + if (app.getAvailability(data) == Availability.unsupported) { + 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', - message: 'Enable the application on your YubiKey to access', + message: 'Enable the \'${app.name}\' application on your YubiKey to access', ); }