Merge pull request #610 from Yubico/nfc-flow

initial improved NFC flow
This commit is contained in:
Dag Heyman 2020-06-09 13:11:09 +02:00 committed by GitHub
commit 88adf77dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 8 deletions

View File

@ -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 ''

View File

@ -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()
}
}
})
}

View File

@ -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')
}

View File

@ -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()

View File

@ -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()
})
}

View File

@ -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()
}
}
}
}