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