mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-29 04:14:52 +03:00
Add reset functionality
This commit is contained in:
parent
ab10894187
commit
084191e467
@ -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):
|
||||
|
||||
|
17
qml/Main.qml
17
qml/Main.qml
@ -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
|
||||
|
@ -201,4 +201,8 @@ Python {
|
||||
function parseQr(screenShots, cb) {
|
||||
do_call('yubikey.controller.parse_qr', [screenShots], cb)
|
||||
}
|
||||
|
||||
function reset() {
|
||||
do_call('yubikey.controller.reset', [])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user