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