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): def _get_version(dev):
if dev.version: if dev.version:
return '.'.join(str(x) for x in 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 '.'.join(str(x) for x in dev._desc_version)
return '' return ''

View File

@ -81,10 +81,12 @@ Pane {
if (touchCredentialNoCode || (hotpCredential if (touchCredentialNoCode || (hotpCredential
&& !hotpCredentialInCoolDown) && !hotpCredentialInCoolDown)
|| customPeriodCredentialNoTouch) { || customPeriodCredentialNoTouch) {
if (touchCredential) {
if (touchCredential && !yubiKey.currentDevice.isNfc) {
navigator.snackBar(qsTr("Touch your YubiKey")) navigator.snackBar(qsTr("Touch your YubiKey"))
} }
if (hotpCredential) {
if (hotpCredential && !yubiKey.currentDevice.isNfc) {
hotpTouchTimer.start() hotpTouchTimer.start()
} }
@ -105,10 +107,17 @@ Pane {
entries.updateEntry(resp) entries.updateEntry(resp)
} else { } else {
if (resp.error_id === 'access_denied') { 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 { } else {
navigator.snackBarError(navigator.getErrorMessage( navigator.snackBarError(navigator.getErrorMessage(
resp.error_id)) resp.error_id))
if (resp.error_id === 'no_device_custom_reader') {
yubiKey.clearCurrentDeviceAndEntries()
}
} }
console.log("calculate failed:", resp.error_id) console.log("calculate failed:", resp.error_id)
} }
@ -143,14 +152,17 @@ Pane {
credential.key) credential.key)
yubiKey.updateNextCalculateAll() yubiKey.updateNextCalculateAll()
navigator.snackBar( navigator.snackBar(
qsTr("Account deleted")) qsTr("Account deleted"))
} else { } else {
navigator.snackBarError( navigator.snackBarError(
resp.error_id) navigator.getErrorMessage(resp.error_id))
console.log("delete failed:", 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') return qsTr('Failed to read credential from QR code')
case 'no_pcscd': case 'no_pcscd':
return qsTr('Is the pcscd/smart card service running?') return qsTr('Is the pcscd/smart card service running?')
case 'no_device_custom_reader':
return qsTr('No device found')
default: default:
return qsTr('Unknown error') return qsTr('Unknown error')
} }

View File

@ -49,6 +49,9 @@ StyledExpansionPanel {
} else { } else {
navigator.snackBarError(getErrorMessage(resp.error_id)) navigator.snackBarError(getErrorMessage(resp.error_id))
console.log("change password failed:", resp.error_id) console.log("change password failed:", resp.error_id)
if (resp.error_id === 'no_device_custom_reader') {
yubiKey.clearCurrentDeviceAndEntries()
}
} }
clearPasswordFields() clearPasswordFields()
navigator.goToSettings() navigator.goToSettings()
@ -65,6 +68,9 @@ StyledExpansionPanel {
} else { } else {
navigator.snackBarError(getErrorMessage(resp.error_id)) navigator.snackBarError(getErrorMessage(resp.error_id))
console.log("set password failed:", resp.error_id) console.log("set password failed:", resp.error_id)
if (resp.error_id === 'no_device_custom_reader') {
yubiKey.clearCurrentDeviceAndEntries()
}
} }
clearPasswordFields() clearPasswordFields()
navigator.goToSettings() navigator.goToSettings()
@ -83,6 +89,9 @@ StyledExpansionPanel {
} else { } else {
navigator.snackBarError(getErrorMessage(resp.error_id)) navigator.snackBarError(getErrorMessage(resp.error_id))
console.log("remove password failed:", resp.error_id) console.log("remove password failed:", resp.error_id)
if (resp.error_id === 'no_device_custom_reader') {
yubiKey.clearCurrentDeviceAndEntries()
}
} }
clearPasswordFields() clearPasswordFields()
navigator.goToSettings() navigator.goToSettings()

View File

@ -33,7 +33,11 @@ StyledExpansionPanel {
resp.error_id)) resp.error_id))
console.log("reset failed:", console.log("reset failed:",
resp.error_id) resp.error_id)
if (resp.error_id === 'no_device_custom_reader') {
yubiKey.clearCurrentDeviceAndEntries()
}
} }
navigator.goToSettings() navigator.goToSettings()
}) })
} }

View File

@ -302,7 +302,12 @@ Python {
} }
if (settings.useCustomReader) { if (settings.useCustomReader) {
checkReaders(settings.customReaderName, callback) if (!currentDevice) {
checkReaders(settings.customReaderName, callback)
} else if (timeToCalculateAll() && !!currentDevice
&& currentDeviceValidated && yubiKey.currentDeviceEnabled("OATH")) {
calculateAll()
}
} else { } else {
checkDescriptors(callback) checkDescriptors(callback)
} }
@ -327,10 +332,15 @@ Python {
currentDevice.hasPassword = true currentDevice.hasPassword = true
currentDeviceValidated = false currentDeviceValidated = false
navigator.goToEnterPasswordIfNotInSettings() navigator.goToEnterPasswordIfNotInSettings()
} else if (resp.error_id === 'no_device_custom_reader') {
navigator.snackBarError(navigator.getErrorMessage(resp.error_id))
clearCurrentDeviceAndEntries()
} else { } else {
clearCurrentDeviceAndEntries() clearCurrentDeviceAndEntries()
console.log("calculateAll failed:", resp.error_id) console.log("calculateAll failed:", resp.error_id)
refreshDevicesDefault() if (!settings.useCustomReader) {
refreshDevicesDefault()
}
} }
} }
} }