WIP: password handling

This commit is contained in:
Dag Heyman 2017-02-08 16:47:28 +01:00
parent 6e321c8157
commit 782da813f9
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
3 changed files with 14 additions and 21 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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()
}
})
}