From fde9f9eb3d5134b84ad3ae974f2eddda1020630b Mon Sep 17 00:00:00 2001 From: Dag Heyman Date: Tue, 26 May 2020 07:54:49 +0200 Subject: [PATCH 1/3] initial improved nfc flow --- qml/CredentialCard.qml | 14 +++++++++++--- qml/YubiKey.qml | 13 +++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/qml/CredentialCard.qml b/qml/CredentialCard.qml index 34b5a945..db681b9c 100644 --- a/qml/CredentialCard.qml +++ b/qml/CredentialCard.qml @@ -81,10 +81,12 @@ Pane { if (touchCredentialNoCode || (hotpCredential && !hotpCredentialInCoolDown) || customPeriodCredentialNoTouch) { - if (touchCredential) { + + if (touchCredential && !yubiKey.currentDevice.isNfc) { navigator.snackBar(qsTr("Touch your YubiKey")) } - if (hotpCredential) { + + if (hotpCredential && !yubiKey.currentDevice.isNfc) { hotpTouchTimer.start() } @@ -105,7 +107,13 @@ Pane { entries.updateEntry(resp) } else { if (resp.error_id === 'access_denied') { - navigator.snackBarError(qsTr("Touch timed out")) + if (!yubiKey.currentDevice.isNfc) { + navigator.snackBarError(qsTr("Touch timed out")) + } else { + navigator.snackBar(qsTr("Re-tap your YubiKey")) + } + } else if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() } else { navigator.snackBarError(navigator.getErrorMessage( resp.error_id)) diff --git a/qml/YubiKey.qml b/qml/YubiKey.qml index f0565fce..efc546af 100644 --- a/qml/YubiKey.qml +++ b/qml/YubiKey.qml @@ -302,7 +302,12 @@ Python { } if (settings.useCustomReader) { - checkReaders(settings.customReaderName, callback) + if (!currentDevice) { + checkReaders(settings.customReaderName, callback) + } else if (timeToCalculateAll() && !!currentDevice + && currentDeviceValidated && yubiKey.currentDeviceEnabled("OATH")) { + calculateAll() + } } else { checkDescriptors(callback) } @@ -327,10 +332,14 @@ Python { currentDevice.hasPassword = true currentDeviceValidated = false navigator.goToEnterPasswordIfNotInSettings() + } else if (resp.error_id === 'no_device_custom_reader') { + clearCurrentDeviceAndEntries() } else { clearCurrentDeviceAndEntries() console.log("calculateAll failed:", resp.error_id) - refreshDevicesDefault() + if (!settings.useCustomReader) { + refreshDevicesDefault() + } } } } From 0e134bffccb554fe8e389e72aceef6677111d711 Mon Sep 17 00:00:00 2001 From: Dag Heyman Date: Mon, 8 Jun 2020 12:41:45 +0200 Subject: [PATCH 2/3] nfc: improve error msgs a bit --- py/yubikey.py | 2 +- qml/CredentialCard.qml | 3 +-- qml/Navigator.qml | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/py/yubikey.py b/py/yubikey.py index 7082255d..ef92441e 100644 --- a/py/yubikey.py +++ b/py/yubikey.py @@ -273,7 +273,7 @@ class Controller(object): def _get_version(dev): if dev.version: return '.'.join(str(x) for x in dev.version) - if dev._desc_version: + if hasattr(dev, '_desc_version') and dev._desc_version: return '.'.join(str(x) for x in dev._desc_version) return '' diff --git a/qml/CredentialCard.qml b/qml/CredentialCard.qml index db681b9c..ea953d1c 100644 --- a/qml/CredentialCard.qml +++ b/qml/CredentialCard.qml @@ -151,12 +151,11 @@ Pane { credential.key) yubiKey.updateNextCalculateAll() - navigator.snackBar( qsTr("Account deleted")) } else { navigator.snackBarError( - resp.error_id) + navigator.getErrorMessage(resp.error_id)) console.log("delete failed:", resp.error_id) } }) diff --git a/qml/Navigator.qml b/qml/Navigator.qml index 0836fdd9..f1ee2f6e 100644 --- a/qml/Navigator.qml +++ b/qml/Navigator.qml @@ -121,6 +121,8 @@ StackView { return qsTr('Failed to read credential from QR code') case 'no_pcscd': return qsTr('Is the pcscd/smart card service running?') + case 'no_device_custom_reader': + return qsTr('No device found') default: return qsTr('Unknown error') } From cab3c009c519bd905b34a710260365effafdcc31 Mon Sep 17 00:00:00 2001 From: Dag Heyman Date: Tue, 9 Jun 2020 13:00:54 +0200 Subject: [PATCH 3/3] nfc: improve error handling --- qml/CredentialCard.qml | 9 +++++++-- qml/SettingsPanelPasswordMgmt.qml | 9 +++++++++ qml/SettingsPanelResetDevice.qml | 4 ++++ qml/YubiKey.qml | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/qml/CredentialCard.qml b/qml/CredentialCard.qml index ea953d1c..bfe7967c 100644 --- a/qml/CredentialCard.qml +++ b/qml/CredentialCard.qml @@ -112,11 +112,12 @@ Pane { } else { navigator.snackBar(qsTr("Re-tap your YubiKey")) } - } else if (resp.error_id === 'no_device_custom_reader') { - yubiKey.clearCurrentDeviceAndEntries() } else { navigator.snackBarError(navigator.getErrorMessage( resp.error_id)) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } console.log("calculate failed:", resp.error_id) } @@ -157,7 +158,11 @@ Pane { navigator.snackBarError( navigator.getErrorMessage(resp.error_id)) console.log("delete failed:", resp.error_id) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } + }) } diff --git a/qml/SettingsPanelPasswordMgmt.qml b/qml/SettingsPanelPasswordMgmt.qml index 1747312e..058a7ece 100644 --- a/qml/SettingsPanelPasswordMgmt.qml +++ b/qml/SettingsPanelPasswordMgmt.qml @@ -49,6 +49,9 @@ StyledExpansionPanel { } else { navigator.snackBarError(getErrorMessage(resp.error_id)) console.log("change password failed:", resp.error_id) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } clearPasswordFields() navigator.goToSettings() @@ -65,6 +68,9 @@ StyledExpansionPanel { } else { navigator.snackBarError(getErrorMessage(resp.error_id)) console.log("set password failed:", resp.error_id) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } clearPasswordFields() navigator.goToSettings() @@ -83,6 +89,9 @@ StyledExpansionPanel { } else { navigator.snackBarError(getErrorMessage(resp.error_id)) console.log("remove password failed:", resp.error_id) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } clearPasswordFields() navigator.goToSettings() diff --git a/qml/SettingsPanelResetDevice.qml b/qml/SettingsPanelResetDevice.qml index 354ab9b6..bab9c0be 100644 --- a/qml/SettingsPanelResetDevice.qml +++ b/qml/SettingsPanelResetDevice.qml @@ -33,7 +33,11 @@ StyledExpansionPanel { resp.error_id)) console.log("reset failed:", resp.error_id) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } + navigator.goToSettings() }) } diff --git a/qml/YubiKey.qml b/qml/YubiKey.qml index efc546af..835e621e 100644 --- a/qml/YubiKey.qml +++ b/qml/YubiKey.qml @@ -333,6 +333,7 @@ Python { currentDeviceValidated = false navigator.goToEnterPasswordIfNotInSettings() } else if (resp.error_id === 'no_device_custom_reader') { + navigator.snackBarError(navigator.getErrorMessage(resp.error_id)) clearCurrentDeviceAndEntries() } else { clearCurrentDeviceAndEntries()