diff --git a/qml/Main.qml b/qml/Main.qml index cc559887..3029cf0f 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -23,13 +23,11 @@ ApplicationWindow { id: passwordPrompt } - onHasDeviceChanged: { + onHasDeviceChanged: { if (device.hasDevice) { - if (!validated) { - device.checkValidation(passwordPrompt.open) + if (!device.validated) { + passwordPrompt.open() } - } else { - device.validated = false } } @@ -244,6 +242,9 @@ ApplicationWindow { errorBox.text = traceback errorBox.open() } + onWrongPassword: { + passwordPrompt.open() + } } Timer { diff --git a/qml/PasswordPrompt.qml b/qml/PasswordPrompt.qml index f6d5b338..61f3b071 100644 --- a/qml/PasswordPrompt.qml +++ b/qml/PasswordPrompt.qml @@ -5,9 +5,13 @@ import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.2 Dialog { + id: passwordPrompt title: qsTr("Enter password") standardButtons: StandardButton.Ok | StandardButton.Cancel - onAccepted: device.validate(password.text) + modality: Qt.ApplicationModal + onAccepted: { + device.validate(password.text); + } ColumnLayout { RowLayout { Label { diff --git a/qml/YubiKey.qml b/qml/YubiKey.qml index 491cb2cd..05c8704a 100644 --- a/qml/YubiKey.qml +++ b/qml/YubiKey.qml @@ -20,6 +20,7 @@ Python { property var queue: [] property bool validated property var passwordKey + signal wrongPassword Component.onCompleted: { importModule('site', function () { @@ -81,27 +82,14 @@ Python { }) } - function checkValidation(cb) { - if (!validated) { - do_call('yubikey.controller.needs_validation', [], function(res) { - if (res === false) { - validated = true - } else { - cb() - } - }) - } - } - function validate(providedPassword) { do_call('yubikey.controller.validate', [providedPassword], function(res) { if (res !== false) { passwordKey = res validated = true } - if (!res) { - passwordKey = null - validated = false + if (res === false) { + wrongPassword() } }) }