Merge pull request #10425 from f321x/qml_password_dialog_wrong_password
qml: PasswordDialog: show error on invalid password
This commit is contained in:
@@ -14,8 +14,10 @@ ElDialog {
|
||||
iconSource: Qt.resolvedUrl('../../icons/lock.png')
|
||||
|
||||
property bool confirmPassword: false
|
||||
property string password
|
||||
property string infotext
|
||||
property string errorMessage
|
||||
|
||||
signal passwordEntered(string password)
|
||||
|
||||
anchors.centerIn: parent
|
||||
width: parent.width * 4/5
|
||||
@@ -84,6 +86,16 @@ ElDialog {
|
||||
password: pw_1.text
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.maximumWidth: parent.width
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: errorMessage
|
||||
wrapMode: Text.Wrap
|
||||
visible: errorMessage
|
||||
color: constants.colorError
|
||||
font.pixelSize: constants.fontSizeLarge
|
||||
}
|
||||
}
|
||||
|
||||
FlatButton {
|
||||
@@ -92,10 +104,13 @@ ElDialog {
|
||||
icon.source: '../../icons/confirmed.png'
|
||||
enabled: confirmPassword ? pw_1.text.length >= 6 && pw_1.text == pw_2.text : true
|
||||
onClicked: {
|
||||
password = pw_1.text
|
||||
passworddialog.doAccept()
|
||||
passwordEntered(pw_1.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearPassword() {
|
||||
pw_1.text = ""
|
||||
pw_2.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,12 +473,13 @@ Pane {
|
||||
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')
|
||||
})
|
||||
dialog.accepted.connect(function() {
|
||||
var success = Daemon.setPassword(dialog.password)
|
||||
dialog.passwordEntered.connect(function(password) {
|
||||
dialog.close()
|
||||
var success = Daemon.setPassword(password)
|
||||
if (success && Biometrics.isEnabled) {
|
||||
if (Biometrics.isAvailable) {
|
||||
// also update the biometric authentication
|
||||
Biometrics.enable(dialog.password)
|
||||
Biometrics.enable(password)
|
||||
} else {
|
||||
// disable biometric authentication as it is not available
|
||||
Biometrics.disable()
|
||||
@@ -538,23 +539,25 @@ Pane {
|
||||
? "\n\n" + qsTr('The new password needs to match the password of any other existing wallet.')
|
||||
: "")
|
||||
})
|
||||
dialog.accepted.connect(function() {
|
||||
dialog.passwordEntered.connect(function(password) {
|
||||
if (Config.walletShouldUseSinglePassword // android
|
||||
&& Daemon.availableWallets.rowCount() > 1 // has more than one wallet
|
||||
&& Daemon.numWalletsWithPassword(dialog.password) < 1 // no other wallet uses this new password
|
||||
&& Daemon.numWalletsWithPassword(password) < 1 // no other wallet uses this new password
|
||||
) {
|
||||
var success = false
|
||||
var error_msg = [
|
||||
dialog.errorMessage = [
|
||||
qsTr('You need to use the password of any other existing wallet.'),
|
||||
qsTr('Using different wallet passwords is not supported.'),
|
||||
].join("\n")
|
||||
dialog.clearPassword()
|
||||
return
|
||||
} else {
|
||||
var success = Daemon.currentWallet.setPassword(dialog.password)
|
||||
var success = Daemon.currentWallet.setPassword(password)
|
||||
if (success && Config.walletShouldUseSinglePassword) {
|
||||
Daemon.singlePassword = dialog.password
|
||||
Daemon.singlePassword = password
|
||||
}
|
||||
var error_msg = qsTr('Password change failed')
|
||||
}
|
||||
dialog.close()
|
||||
if (success && Biometrics.isEnabled) {
|
||||
// unlikely to happen as this means the user somehow moved from
|
||||
// a unified password to differing passwords
|
||||
|
||||
@@ -852,11 +852,13 @@ ApplicationWindow
|
||||
// 'payment_auth' should have been converted to 'wallet' at this point
|
||||
if (method === 'wallet' || method === 'wallet_password_only') {
|
||||
var dialog = app.passwordDialog.createObject(app, authMessage ? {'title': authMessage} : {})
|
||||
dialog.accepted.connect(function() {
|
||||
if (Daemon.currentWallet.verifyPassword(dialog.password)) {
|
||||
dialog.passwordEntered.connect(function(password) {
|
||||
if (Daemon.currentWallet.verifyPassword(password)) {
|
||||
dialog.close()
|
||||
qtobject.authProceed()
|
||||
} else {
|
||||
qtobject.authCancel()
|
||||
dialog.clearPassword()
|
||||
dialog.errorMessage = qsTr("Invalid Password")
|
||||
}
|
||||
})
|
||||
dialog.rejected.connect(function() {
|
||||
|
||||
Reference in New Issue
Block a user