mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-25 03:03:50 +03:00
improved error messages
This commit is contained in:
parent
4e7ad56634
commit
2cca27adf1
@ -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
|
||||||
|
@ -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',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user