mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-06 02:37:21 +03:00
Modify set password checks
This commit is contained in:
parent
343cacce9b
commit
9a6f681831
45
qml/Main.qml
45
qml/Main.qml
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,9 @@ Python {
|
||||
function setPassword(password) {
|
||||
do_call('yubikey.controller.set_password', [password, passwordKey],
|
||||
function () {
|
||||
validate(password)
|
||||
if (password !== null) {
|
||||
validate(password)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user