Add reset functionality

This commit is contained in:
Dag Heyman 2017-02-17 08:52:34 +01:00
parent ab10894187
commit 084191e467
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
3 changed files with 25 additions and 3 deletions

View File

@ -127,7 +127,6 @@ class Controller(object):
def _calculate_all(self, timestamp, password_key):
dev = self._descriptor.open_device(TRANSPORT.CCID)
controller = OathController(dev.driver)
if controller.locked and password_key is not None:
controller.validate(password_key)
creds = controller.calculate_all(timestamp)
@ -146,7 +145,6 @@ class Controller(object):
key += '=' * (-len(key) % 8) # Support unpadded
return b32decode(key)
def parse_qr(self, screenshots):
for s in screenshots:
data = b64decode(s['data'])
@ -154,6 +152,11 @@ class Controller(object):
for qr in qrparse.parse_qr_codes(image, 2):
return parse_uri(qrdecode.decode_qr_data(qr))
def reset(self):
dev = self._descriptor.open_device(TRANSPORT.CCID)
controller = OathController(dev.driver)
controller.reset()
class PixelImage(object):

View File

@ -64,6 +64,10 @@ ApplicationWindow {
text: qsTr('Set password...')
onTriggered: setPassword.open()
}
MenuItem {
text: qsTr('Reset...')
onTriggered: reset.open()
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit()
@ -111,7 +115,6 @@ ApplicationWindow {
text: qsTr("Password confirmation does not match password.")
standardButtons: StandardButton.Ok
onAccepted: setPassword.open()
}
MessageDialog {
@ -122,6 +125,18 @@ ApplicationWindow {
standardButtons: StandardButton.Ok
}
MessageDialog {
id: reset
icon: StandardIcon.Critical
title: qsTr("Reset OATH functionality")
text: qsTr("This will delete all OATH credentials stored on the device, and reset the password. This action cannot be undone. Are you sure you want to reset the device?")
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {
device.reset()
device.refreshCredentials()
}
}
MouseArea {
enabled: device.hasDevice
anchors.fill: parent

View File

@ -201,4 +201,8 @@ Python {
function parseQr(screenShots, cb) {
do_call('yubikey.controller.parse_qr', [screenShots], cb)
}
function reset() {
do_call('yubikey.controller.reset', [])
}
}