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 34b5a945..bfe7967c 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,10 +107,17 @@ 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 { navigator.snackBarError(navigator.getErrorMessage( resp.error_id)) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } console.log("calculate failed:", resp.error_id) } @@ -143,14 +152,17 @@ 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) + if (resp.error_id === 'no_device_custom_reader') { + yubiKey.clearCurrentDeviceAndEntries() + } } + }) } 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') } 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 f0565fce..835e621e 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,15 @@ Python { currentDevice.hasPassword = true currentDeviceValidated = false navigator.goToEnterPasswordIfNotInSettings() + } else if (resp.error_id === 'no_device_custom_reader') { + navigator.snackBarError(navigator.getErrorMessage(resp.error_id)) + clearCurrentDeviceAndEntries() } else { clearCurrentDeviceAndEntries() console.log("calculateAll failed:", resp.error_id) - refreshDevicesDefault() + if (!settings.useCustomReader) { + refreshDevicesDefault() + } } } }