1
0

qml: enforce single password on password change

If a qml user with non-uniform wallet passwords tries to change their wallet
password this will force them to change it to a password that is used by
at least one other wallet. This will guide them towards a single wallet
password and prevents the number of different passwords from increasing.
This commit is contained in:
f321x
2025-12-18 11:12:16 +01:00
parent 378a9e6112
commit 02abc0e6cd

View File

@@ -525,18 +525,33 @@ Pane {
confirmPassword: true, confirmPassword: true,
title: qsTr('Enter new password'), title: qsTr('Enter new password'),
infotext: qsTr('If you forget your password, you\'ll need to restore from seed. Please make sure you have your seed stored safely') infotext: qsTr('If you forget your password, you\'ll need to restore from seed. Please make sure you have your seed stored safely')
+ (Daemon.availableWallets.rowCount() > 1 && Config.walletShouldUseSinglePassword
? "\n\n" + qsTr('The new password needs to match the password of any other existing wallet.')
: "")
}) })
dialog.accepted.connect(function() { dialog.accepted.connect(function() {
var success = Daemon.currentWallet.setPassword(dialog.password) if (Config.walletShouldUseSinglePassword // android
if (success && Config.walletShouldUseSinglePassword) { && Daemon.availableWallets.rowCount() > 1 // has more than one wallet
Daemon.singlePassword = dialog.password && Daemon.numWalletsWithPassword(dialog.password) < 1 // no other wallet uses this new password
) {
var success = false
var error_msg = [
qsTr('You need to use the password of any other existing wallet.'),
qsTr('Using different wallet passwords is not supported.'),
].join("\n")
} else {
var success = Daemon.currentWallet.setPassword(dialog.password)
if (success && Config.walletShouldUseSinglePassword) {
Daemon.singlePassword = dialog.password
}
var error_msg = qsTr('Password change failed')
} }
var done_dialog = app.messageDialog.createObject(app, { var done_dialog = app.messageDialog.createObject(app, {
title: success ? qsTr('Success') : qsTr('Error'), title: success ? qsTr('Success') : qsTr('Error'),
iconSource: success iconSource: success
? Qt.resolvedUrl('../../icons/info.png') ? Qt.resolvedUrl('../../icons/info.png')
: Qt.resolvedUrl('../../icons/warning.png'), : Qt.resolvedUrl('../../icons/warning.png'),
text: success ? qsTr('Password changed') : qsTr('Password change failed') text: success ? qsTr('Password changed') : error_msg
}) })
done_dialog.open() done_dialog.open()
}) })