mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 00:57:26 +03:00
Changes to bio add, delete, list
This commit is contained in:
parent
ddfb079d07
commit
7ceca60bf5
@ -153,6 +153,12 @@ class Controller(object):
|
|||||||
|
|
||||||
_state = None
|
_state = None
|
||||||
|
|
||||||
|
_enroller = None
|
||||||
|
_template_id = None
|
||||||
|
_remaining = None
|
||||||
|
_bio = None
|
||||||
|
_conn = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.settings = Settings('oath')
|
self.settings = Settings('oath')
|
||||||
|
|
||||||
@ -931,27 +937,35 @@ class Controller(object):
|
|||||||
|
|
||||||
def bio_enroll(self, pin, name):
|
def bio_enroll(self, pin, name):
|
||||||
try:
|
try:
|
||||||
with self._open_device([FidoConnection]) as conn:
|
if self._conn is None:
|
||||||
ctap2 = Ctap2(conn)
|
self._conn = self._open_device([FidoConnection])
|
||||||
|
if self._enroller is None :
|
||||||
|
ctap2 = Ctap2(self._conn)
|
||||||
client_pin = ClientPin(ctap2)
|
client_pin = ClientPin(ctap2)
|
||||||
token = client_pin.get_pin_token(pin, ClientPin.PERMISSION.BIO_ENROLL)
|
token = client_pin.get_pin_token(pin, ClientPin.PERMISSION.BIO_ENROLL)
|
||||||
bio = FPBioEnrollment(ctap2, client_pin.protocol, token)
|
self._bio = FPBioEnrollment(ctap2, client_pin.protocol, token)
|
||||||
|
|
||||||
enroller = bio.enroll()
|
self._enroller = self._bio.enroll()
|
||||||
template_id = None
|
self._template_id = None
|
||||||
while template_id is None:
|
if self._template_id is None:
|
||||||
try:
|
try:
|
||||||
logger.debug("Place your finger against the sensor now...")
|
|
||||||
template_id = enroller.capture()
|
logger.debug("Place your finger against the sensor now...")
|
||||||
remaining = enroller.remaining
|
self._template_id = self._enroller.capture()
|
||||||
if remaining:
|
self._remaining = self._enroller.remaining
|
||||||
logger.debug(f"{remaining} more scans needed.")
|
if self._remaining:
|
||||||
except:
|
logger.debug(f"{self._remaining} more scans needed.")
|
||||||
logger.debug("Failed to capture")
|
return success({'remaining': self._remaining})
|
||||||
logger.debug("Capture complete.")
|
except:
|
||||||
bio.set_name(template_id, name)
|
logger.debug("Failed to capture")
|
||||||
return success()
|
logger.debug(f"{self._remaining} more scans needed.")
|
||||||
|
return failure(self._remaining)
|
||||||
|
logger.debug("Capture complete.")
|
||||||
|
self._bio.set_name(self._template_id, name)
|
||||||
|
self._conn.close()
|
||||||
|
return success()
|
||||||
except CtapError as e:
|
except CtapError as e:
|
||||||
|
self._conn.close()
|
||||||
if e.code == CtapError.ERR.PIN_AUTH_BLOCKED:
|
if e.code == CtapError.ERR.PIN_AUTH_BLOCKED:
|
||||||
return failure('PIN authentication is currently blocked. '
|
return failure('PIN authentication is currently blocked. '
|
||||||
'Remove and re-insert the YubiKey.')
|
'Remove and re-insert the YubiKey.')
|
||||||
@ -983,6 +997,7 @@ class Controller(object):
|
|||||||
f"Multiple matches for NAME={template_id}. "
|
f"Multiple matches for NAME={template_id}. "
|
||||||
"Delete by template ID instead."
|
"Delete by template ID instead."
|
||||||
)
|
)
|
||||||
|
return failure("multiple_matches")
|
||||||
key = matches[0]
|
key = matches[0]
|
||||||
|
|
||||||
name = enrollments[key]
|
name = enrollments[key]
|
||||||
|
@ -32,10 +32,20 @@ StyledExpansionPanel {
|
|||||||
function enroll() {
|
function enroll() {
|
||||||
yubiKey.bioEnroll(currentPinField.text, nameField.text, function (resp) {
|
yubiKey.bioEnroll(currentPinField.text, nameField.text, function (resp) {
|
||||||
if (resp.success) {
|
if (resp.success) {
|
||||||
navigator.goToSettings()
|
if (resp.remaining > 0) {
|
||||||
navigator.snackBar(qsTr("Fingerprint added"))
|
console.log("success")
|
||||||
|
enroll()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
navigator.goToSettings()
|
||||||
|
navigator.snackBar(qsTr("Fingerprint added"))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
navigator.snackBarError(qsTr("Fingerprint not added"))
|
if (resp.error_id > 0) {
|
||||||
|
console.log("fail")
|
||||||
|
enroll()
|
||||||
|
}
|
||||||
|
//navigator.snackBarError(qsTr("Fingerprint not added"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,12 @@ StyledExpansionPanel {
|
|||||||
navigator.goToSettings()
|
navigator.goToSettings()
|
||||||
navigator.snackBar(qsTr("Fingerprint deleted"))
|
navigator.snackBar(qsTr("Fingerprint deleted"))
|
||||||
} else {
|
} else {
|
||||||
navigator.snackBarError(qsTr("Fingerprint not deleted"))
|
if (resp.error_id === "multiple_matches") {
|
||||||
|
navigator.snackBarError(qsTr("Multiple matches. Delete by template ID instead"))
|
||||||
|
} else {
|
||||||
|
|
||||||
|
navigator.snackBarError(qsTr("Fingerprint not deleted"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ StyledExpansionPanel {
|
|||||||
StyledButton {
|
StyledButton {
|
||||||
id: applyField
|
id: applyField
|
||||||
text: qsTr("List")
|
text: qsTr("List")
|
||||||
enabled: nameField.text.length > 15 ? false : true
|
|
||||||
onClicked: yubiKey.fidoList(currentPinField.text)
|
onClicked: yubiKey.fidoList(currentPinField.text)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user