Modify set password checks

This commit is contained in:
Dag Heyman 2017-03-16 16:34:00 +01:00
parent 343cacce9b
commit 9a6f681831
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
3 changed files with 27 additions and 31 deletions

View File

@ -78,39 +78,14 @@ ApplicationWindow {
}
}
function saveSettings() {
settings.slotMode = settingsDialog.slotMode
settings.slot1 = settingsDialog.slot1
settings.slot2 = settingsDialog.slot2
settings.slot1digits = settingsDialog.slot1digits
settings.slot2digits = settingsDialog.slot2digits
}
SetPassword {
id: setPassword
onAccepted: {
if (setPassword.newPassword !== setPassword.confirmPassword) {
noMatch.open()
} else {
if (setPassword.newPassword != "") {
device.setPassword(setPassword.newPassword)
} else {
device.setPassword(null)
}
passwordUpdated.open()
}
trySetPassword()
passwordUpdated.open()
}
}
MessageDialog {
id: noMatch
icon: StandardIcon.Critical
title: qsTr("Passwords does not match")
text: qsTr("Password confirmation does not match password.")
standardButtons: StandardButton.Ok
onAccepted: setPassword.open()
}
MessageDialog {
id: passwordUpdated
icon: StandardIcon.Information
@ -572,4 +547,20 @@ ApplicationWindow {
function getTitle() {
return qsTr("Yubico Authenticator") + (settings.slotMode ? qsTr(" [Slot mode]") : '')
}
function saveSettings() {
settings.slotMode = settingsDialog.slotMode
settings.slot1 = settingsDialog.slot1
settings.slot2 = settingsDialog.slot2
settings.slot1digits = settingsDialog.slot1digits
settings.slot2digits = settingsDialog.slot2digits
}
function trySetPassword() {
if (setPassword.newPassword.length > 0) {
device.setPassword(setPassword.newPassword)
} else {
device.setPassword(null)
}
}
}

View File

@ -9,7 +9,7 @@ DefaultDialog {
title: qsTr("Set new password")
modality: Qt.ApplicationModal
property string newPassword: newPassword.text
property string confirmPassword: confirmPassword.text
property bool matchingPasswords: newPassword.text === confirmPassword.text
ColumnLayout {
anchors.fill: parent
@ -40,6 +40,7 @@ DefaultDialog {
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
Button {
text: qsTr("Set password")
enabled: matchingPasswords
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
onClicked: promptAccepted()
}
@ -50,7 +51,9 @@ DefaultDialog {
}
}
function promptAccepted() {
close()
accepted()
if (matchingPasswords) {
close()
accepted()
}
}
}

View File

@ -164,7 +164,9 @@ Python {
function setPassword(password) {
do_call('yubikey.controller.set_password', [password, passwordKey],
function () {
validate(password)
if (password !== null) {
validate(password)
}
})
}