mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-06 02:37:21 +03:00
Better handling of missing modes.
This commit is contained in:
parent
2e16fc20f9
commit
f8439c485b
@ -89,13 +89,15 @@ class Controller(object):
|
||||
return [c.to_dict() for c in result]
|
||||
|
||||
def _read_slot_cred(self, slot, digits, timestamp):
|
||||
dev = self._descriptor.open_device(TRANSPORT.OTP)
|
||||
try:
|
||||
dev = self._descriptor.open_device(TRANSPORT.OTP)
|
||||
code = dev.driver.calculate(slot, challenge=timestamp, totp=True, digits=int(digits), wait_for_touch=False)
|
||||
return Credential(self._slot_name(slot), code=code, oath_type='totp', touch=False, algo='SHA1', expiration=self._expiration(timestamp))
|
||||
except YkpersError as e:
|
||||
if e.errno == 11:
|
||||
return Credential(self._slot_name(slot), oath_type='totp', touch=True, algo='SHA1')
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
||||
def _slot_name(self, slot):
|
||||
@ -105,9 +107,12 @@ class Controller(object):
|
||||
return ((timestamp + 30) // 30) * 30
|
||||
|
||||
def needs_validation(self):
|
||||
dev = self._descriptor.open_device(TRANSPORT.CCID)
|
||||
controller = OathController(dev.driver)
|
||||
return controller.locked
|
||||
try:
|
||||
dev = self._descriptor.open_device(TRANSPORT.CCID)
|
||||
controller = OathController(dev.driver)
|
||||
return controller.locked
|
||||
except:
|
||||
return False
|
||||
|
||||
def validate(self, password):
|
||||
dev = self._descriptor.open_device(TRANSPORT.CCID)
|
||||
|
@ -182,12 +182,13 @@ ApplicationWindow {
|
||||
|
||||
onHasDeviceChanged: {
|
||||
if (device.hasDevice) {
|
||||
if(!settings.slotMode) {
|
||||
if(!settings.slotMode && device.hasCCID) {
|
||||
device.promptOrSkip(passwordPrompt)
|
||||
}
|
||||
} else {
|
||||
passwordPrompt.close()
|
||||
addCredential.close()
|
||||
expiration = 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,9 +574,9 @@ ApplicationWindow {
|
||||
|
||||
function refreshDependingOnMode(force) {
|
||||
if (hasDevice) {
|
||||
if (settings.slotMode) {
|
||||
if (settings.slotMode && device.hasOTP) {
|
||||
device.refreshSlotCredentials([settings.slot1, settings.slot2], getSlotDigitsSettings(), force)
|
||||
} else {
|
||||
} else if (!settings.slotMode && device.hasCCID) {
|
||||
device.refreshCCIDCredentials(force)
|
||||
}
|
||||
}
|
||||
|
@ -70,12 +70,13 @@ Python {
|
||||
nDevices = n
|
||||
if (nDevices == 1) {
|
||||
do_call('yubikey.controller.refresh', [], function (dev) {
|
||||
hasDevice = dev !== undefined && dev !== null
|
||||
name = dev ? dev.name : ''
|
||||
version = dev ? dev.version : ''
|
||||
serial = dev ? dev.serial : ''
|
||||
enabled = dev ? dev.enabled : []
|
||||
connections = dev ? dev.connections : []
|
||||
hasDevice = dev !== undefined && dev !== null
|
||||
|
||||
})
|
||||
} else if (hasDevice) {
|
||||
hasDevice = false
|
||||
|
Loading…
Reference in New Issue
Block a user