mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-06 02:37:21 +03:00
Add set password functionality
This commit is contained in:
parent
5fef9d5513
commit
dcfe627844
@ -86,6 +86,18 @@ class Controller(object):
|
||||
except:
|
||||
return False
|
||||
|
||||
def set_password(self, new_password, password_key):
|
||||
dev = self._descriptor.open_device(TRANSPORT.CCID)
|
||||
controller = OathController(dev.driver)
|
||||
if controller.locked and password_key is not None:
|
||||
controller.validate(a2b_hex(password_key))
|
||||
if new_password is not None:
|
||||
key = derive_key(controller.id, new_password)
|
||||
controller.set_password(key)
|
||||
else:
|
||||
controller.clear_password()
|
||||
|
||||
|
||||
def add_credential(self, name, key, oath_type, digits, algo, touch, password_key):
|
||||
dev = self._descriptor.open_device(TRANSPORT.CCID)
|
||||
controller = OathController(dev.driver)
|
||||
|
10
qml/Main.qml
10
qml/Main.qml
@ -89,8 +89,18 @@ ApplicationWindow {
|
||||
|
||||
SetPassword {
|
||||
id: setPassword
|
||||
onAccepted: passwordUpdated.open()
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: passwordUpdated
|
||||
icon: StandardIcon.Information
|
||||
title: qsTr("Password set")
|
||||
text: qsTr("A new password has been set.")
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
enabled: device.hasDevice
|
||||
anchors.fill: parent
|
||||
|
@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
Dialog {
|
||||
id: passwordPrompt
|
||||
id: setPasswordPrompt
|
||||
title: qsTr("Set new password")
|
||||
standardButtons: StandardButton.NoButton
|
||||
|
||||
@ -61,7 +61,8 @@ Dialog {
|
||||
if (newPassword.text !== confirmPassword.text) {
|
||||
noMatch.open()
|
||||
} else {
|
||||
close()
|
||||
device.setPassword(newPassword.text)
|
||||
accept()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,13 @@ Python {
|
||||
})
|
||||
}
|
||||
|
||||
function setPassword(password) {
|
||||
console.log('PROVIDED PW ', password)
|
||||
do_call('yubikey.controller.set_password', [password, passwordKey], function() {
|
||||
validate(password)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function refreshCredentials() {
|
||||
var now = Math.floor(Date.now() / 1000)
|
||||
|
Loading…
Reference in New Issue
Block a user