2021-08-11 09:55:59 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.12
|
2021-09-09 14:04:05 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2022-03-07 22:59:38 +00:00
|
|
|
import shared.views 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.controls 1.0
|
2022-07-20 12:34:44 +00:00
|
|
|
import shared.stores 1.0
|
2021-08-11 09:55:59 +00:00
|
|
|
|
2021-09-09 14:04:05 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-03-01 15:59:38 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import "../views"
|
2021-09-09 14:04:05 +00:00
|
|
|
|
|
|
|
StatusModal {
|
2022-02-10 15:44:40 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property var privacyStore
|
|
|
|
signal passwordChanged()
|
|
|
|
|
2022-03-29 12:42:55 +00:00
|
|
|
function onChangePasswordResponse(success, errorMsg) {
|
2021-12-30 12:39:47 +00:00
|
|
|
if (success) {
|
2022-12-16 14:04:03 +00:00
|
|
|
if (Qt.platform.os === "osx" && localAccountSettings.storeToKeychainValue !== Constants.keychain.storedValue.never) {
|
|
|
|
localAccountSettings.storeToKeychainValue = Constants.keychain.storedValue.notNow;
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
2022-02-10 15:44:40 +00:00
|
|
|
passwordChanged()
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-03-01 15:59:38 +00:00
|
|
|
view.reset()
|
2022-03-29 12:42:55 +00:00
|
|
|
view.errorMsgText = errorMsg
|
2022-03-01 15:59:38 +00:00
|
|
|
console.warn("TODO: Display error message when change password action failure! ")
|
2022-01-10 23:30:39 +00:00
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
d.passwordProcessing = "";
|
2023-02-07 20:06:09 +00:00
|
|
|
submitBtn.loading = false;
|
2021-12-30 12:39:47 +00:00
|
|
|
}
|
2021-08-11 09:55:59 +00:00
|
|
|
|
2022-05-06 12:47:46 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
// We temporarly store the password during "changePassword" call
|
|
|
|
// to store it to KeyChain after successfull change operation.
|
|
|
|
property string passwordProcessing: ""
|
|
|
|
|
2022-05-06 12:47:46 +00:00
|
|
|
function submit() {
|
|
|
|
submitBtn.loading = true
|
|
|
|
// ChangePassword operation blocks the UI so loading = true; will never have any affect until changePassword/createPassword is done.
|
|
|
|
// Getting around it with a small pause (timer) in order to get the desired behavior
|
|
|
|
pause.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-30 12:39:47 +00:00
|
|
|
Connections {
|
2022-02-10 15:44:40 +00:00
|
|
|
target: root.privacyStore.privacyModule
|
2023-01-18 09:25:36 +00:00
|
|
|
function onPasswordChanged(success: bool, errorMsg: string) {
|
|
|
|
onChangePasswordResponse(success, errorMsg)
|
|
|
|
}
|
2021-08-11 09:55:59 +00:00
|
|
|
}
|
|
|
|
|
2022-03-01 15:59:38 +00:00
|
|
|
width: 480
|
|
|
|
height: 546
|
2023-03-24 09:39:44 +00:00
|
|
|
closePolicy: submitBtn.loading? Popup.NoAutoClose : Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
hasCloseButton: !submitBtn.loading
|
2022-03-01 15:59:38 +00:00
|
|
|
header.title: qsTr("Change password")
|
2021-08-11 09:55:59 +00:00
|
|
|
|
2022-03-01 15:59:38 +00:00
|
|
|
onOpened: view.reset()
|
2021-08-11 09:55:59 +00:00
|
|
|
|
2022-03-01 15:59:38 +00:00
|
|
|
PasswordView {
|
|
|
|
id: view
|
2022-10-11 13:58:34 +00:00
|
|
|
anchors {
|
|
|
|
fill: parent
|
|
|
|
topMargin: Style.current.padding
|
|
|
|
bottomMargin: Style.current.padding
|
|
|
|
leftMargin: Style.current.xlPadding
|
|
|
|
rightMargin: Style.current.xlPadding
|
|
|
|
}
|
2022-07-20 12:34:44 +00:00
|
|
|
passwordStrengthScoreFunction: RootStore.getPasswordStrengthScore
|
2022-03-01 15:59:38 +00:00
|
|
|
titleVisible: false
|
|
|
|
introText: qsTr("Change password used to unlock Status on this device & sign transactions.")
|
|
|
|
createNewPsw: false
|
2022-05-06 12:47:46 +00:00
|
|
|
onReturnPressed: if(submitBtn.enabled) d.submit()
|
2021-08-11 09:55:59 +00:00
|
|
|
}
|
|
|
|
|
2021-09-09 14:04:05 +00:00
|
|
|
rightButtons: [
|
2021-08-11 09:55:59 +00:00
|
|
|
StatusButton {
|
|
|
|
id: submitBtn
|
2022-08-24 09:51:20 +00:00
|
|
|
objectName: "changePasswordModalSubmitButton"
|
2022-12-16 14:04:03 +00:00
|
|
|
text: qsTr("Change password and restart Status")
|
2022-03-01 15:59:38 +00:00
|
|
|
enabled: !submitBtn.loading && view.ready
|
2021-09-09 14:04:05 +00:00
|
|
|
|
|
|
|
property Timer sim: Timer {
|
|
|
|
id: pause
|
|
|
|
interval: 20
|
|
|
|
onTriggered: {
|
2022-03-01 15:59:38 +00:00
|
|
|
// Change current password call action to the backend
|
2022-06-22 12:16:21 +00:00
|
|
|
d.passwordProcessing = view.newPswText
|
2022-03-01 15:59:38 +00:00
|
|
|
root.privacyStore.changePassword(view.currentPswText, view.newPswText)
|
2021-09-09 14:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-11 09:55:59 +00:00
|
|
|
|
2022-05-06 12:47:46 +00:00
|
|
|
onClicked: { d.submit() }
|
2021-08-11 09:55:59 +00:00
|
|
|
}
|
2021-09-09 14:04:05 +00:00
|
|
|
]
|
2022-03-01 15:59:38 +00:00
|
|
|
|
|
|
|
// By clicking anywhere outside password entries fields or focusable element in the view, it is needed to check if passwords entered matches
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
z: view.zBehind // Behind focusable components in the view
|
|
|
|
onClicked: { view.checkPasswordMatches() }
|
|
|
|
}
|
2021-08-11 09:55:59 +00:00
|
|
|
}
|