feat(@desktop): change password
This commit is contained in:
parent
87b3f4f2c0
commit
8310a36bde
|
@ -2,6 +2,7 @@ import NimQml, sequtils, strutils, sugar, os, json, chronicles
|
|||
import views/[mailservers_list, ens_manager, contacts, devices, mailservers, mnemonic, network, fleets, profile_info, device_list, dapp_list, profile_picture, profile_settings, muted_chats]
|
||||
import chronicles
|
||||
import ../chat/views/channels_list
|
||||
import ../../status/libstatus/accounts as status_accounts
|
||||
import ../../status/profile/profile
|
||||
import ../../status/profile as status_profile
|
||||
import ../../status/contacts as status_contacts
|
||||
|
@ -120,6 +121,11 @@ QtObject:
|
|||
QtProperty[QVariant] ens:
|
||||
read = getEnsManager
|
||||
|
||||
proc changePassword(self: ProfileView, password: string, newPassword: string): bool {.slot.} =
|
||||
if not status_accounts.changeDatabasePassword(self.profile.address, password, newPassword):
|
||||
return false
|
||||
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
|
||||
|
||||
proc getLinkPreviewWhitelist*(self: ProfileView): string {.slot.} =
|
||||
result = $(self.status.profile.getLinkPreviewWhitelist())
|
||||
|
||||
|
|
|
@ -238,6 +238,13 @@ proc verifyAccountPassword*(address: string, password: string): bool =
|
|||
|
||||
return false
|
||||
|
||||
proc changeDatabasePassword*(keyUID: string, password: string, newPassword: string): bool =
|
||||
let hashedPassword = hashPassword(password)
|
||||
let hashedNewPassword = hashPassword(newPassword)
|
||||
let changeResult = $status_go.changeDatabasePassword(keyUID, hashedPassword, hashedNewPassword)
|
||||
let error = parseJson(changeResult)["error"].getStr
|
||||
return error == ""
|
||||
|
||||
proc multiAccountImportMnemonic*(mnemonic: string): GeneratedAccount =
|
||||
let mnemonicJson = %* {
|
||||
"mnemonicPhrase": mnemonic,
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.12
|
||||
import StatusQ.Controls 0.1
|
||||
import "../../../../imports"
|
||||
import "../../../../shared"
|
||||
|
||||
ModalPopup {
|
||||
id: popup
|
||||
title: qsTr("Change password")
|
||||
height: 510
|
||||
|
||||
onOpened: {
|
||||
reset()
|
||||
}
|
||||
|
||||
property bool loading: false
|
||||
property bool firstPasswordFieldValid: false
|
||||
property bool repeatPasswordFieldValid: false
|
||||
property string passwordValidationError: ""
|
||||
property string repeatPasswordValidationError: ""
|
||||
property string changePasswordError: ""
|
||||
|
||||
function reset() {
|
||||
currentPasswordField.text = ""
|
||||
firstPasswordField.text = ""
|
||||
repeatPasswordField.text = ""
|
||||
currentPasswordField.forceActiveFocus(Qt.MouseFocusReason)
|
||||
|
||||
firstPasswordFieldValid = false
|
||||
repeatPasswordFieldValid = false
|
||||
passwordValidationError = ""
|
||||
repeatPasswordValidationError = ""
|
||||
changePasswordError = ""
|
||||
loading = false
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 32
|
||||
spacing: Style.current.xlPadding
|
||||
|
||||
Input {
|
||||
id: currentPasswordField
|
||||
anchors.left: undefined
|
||||
anchors.right: undefined
|
||||
Layout.fillWidth: true
|
||||
placeholderText: qsTr("Current password")
|
||||
textField.echoMode: TextInput.Password
|
||||
onTextChanged: {
|
||||
changePasswordError = ""
|
||||
}
|
||||
}
|
||||
|
||||
Input {
|
||||
id: firstPasswordField
|
||||
anchors.left: undefined
|
||||
anchors.right: undefined
|
||||
Layout.fillWidth: true
|
||||
//% "New password..."
|
||||
placeholderText: qsTrId("new-password...")
|
||||
textField.echoMode: TextInput.Password
|
||||
onTextChanged: {
|
||||
[firstPasswordFieldValid, passwordValidationError] =
|
||||
Utils.validatePasswords("first", firstPasswordField, repeatPasswordField);
|
||||
}
|
||||
}
|
||||
|
||||
Input {
|
||||
id: repeatPasswordField
|
||||
anchors.left: undefined
|
||||
anchors.right: undefined
|
||||
Layout.fillWidth: true
|
||||
enabled: firstPasswordFieldValid
|
||||
//% "Confirm password…"
|
||||
placeholderText: qsTrId("confirm-password…")
|
||||
textField.echoMode: TextInput.Password
|
||||
Keys.onReturnPressed: function(event) {
|
||||
if (submitBtn.enabled) {
|
||||
submitBtn.clicked(event)
|
||||
}
|
||||
}
|
||||
onTextChanged: {
|
||||
[repeatPasswordFieldValid, repeatPasswordValidationError] =
|
||||
Utils.validatePasswords("repeat", firstPasswordField, repeatPasswordField);
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: validationError
|
||||
text: passwordValidationError || repeatPasswordValidationError || changePasswordError
|
||||
Layout.preferredWidth: 340
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: Style.current.danger
|
||||
font.pixelSize: 12
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: qsTr("Status app will be terminated after password change. You need to restart it to login using the new password.")
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.preferredWidth: 340
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
color: Style.current.secondaryText
|
||||
font.pixelSize: 12
|
||||
}
|
||||
}
|
||||
|
||||
footer: Item {
|
||||
width: parent.width
|
||||
height: submitBtn.height
|
||||
|
||||
StatusButton {
|
||||
id: submitBtn
|
||||
anchors.right: parent.right
|
||||
text: qsTr("Change password")
|
||||
enabled: popup.firstPasswordFieldValid && popup.repeatPasswordFieldValid && !popup.loading
|
||||
state: popup.loading ? "pending" : "default"
|
||||
|
||||
onClicked: {
|
||||
popup.loading = true
|
||||
Qt.callLater(function() {
|
||||
if (profileModel.changePassword(currentPasswordField.text, firstPasswordField.text)) {
|
||||
popup.close()
|
||||
} else {
|
||||
reset()
|
||||
changePasswordError = qsTr("Failed to change password.")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ Item {
|
|||
id: labelSecurity
|
||||
//% "Security"
|
||||
text: qsTrId("security")
|
||||
bottomPadding: 4
|
||||
bottomPadding: Style.current.halfPadding
|
||||
}
|
||||
|
||||
StatusSettingsLineButton {
|
||||
|
@ -38,10 +38,21 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
StatusSettingsLineButton {
|
||||
text: qsTr("Change password")
|
||||
onClicked: {
|
||||
changePasswordModal.open()
|
||||
}
|
||||
}
|
||||
|
||||
BackupSeedModal {
|
||||
id: backupSeedModal
|
||||
}
|
||||
|
||||
ChangePasswordModal {
|
||||
id: changePasswordModal
|
||||
}
|
||||
|
||||
Item {
|
||||
id: spacer1
|
||||
height: Style.current.bigPadding
|
||||
|
@ -57,7 +68,7 @@ Item {
|
|||
//% "Privacy"
|
||||
text: qsTrId("privacy")
|
||||
topPadding: Style.current.padding
|
||||
bottomPadding: 4
|
||||
bottomPadding: Style.current.halfPadding
|
||||
}
|
||||
|
||||
StatusSettingsLineButton {
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import "../../../../imports"
|
||||
import "../../../../shared"
|
||||
import "../../../../shared/status"
|
||||
|
||||
Item {
|
||||
id: signoutContainer
|
||||
width: 200
|
||||
height: 200
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
clip: true
|
||||
|
||||
StyledText {
|
||||
id: txtTitle
|
||||
//% "Sign out controls"
|
||||
text: qsTrId("sign-out-controls")
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 24
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 24
|
||||
font.weight: Font.Bold
|
||||
font.pixelSize: 20
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
id: btnLogout
|
||||
anchors.top: txtTitle.bottom
|
||||
anchors.topMargin: Style.current.padding
|
||||
//% "Logout"
|
||||
// text: qsTrId("logout")
|
||||
//% "Exit"
|
||||
text: qsTrId("exit")
|
||||
|
||||
onClicked: {
|
||||
// profileModel.logout();
|
||||
Qt.quit();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,5 @@ NotificationsContainer 1.0 NotificationsContainer.qml
|
|||
AdvancedContainer 1.0 AdvancedContainer.qml
|
||||
HelpContainer 1.0 HelpContainer.qml
|
||||
AboutContainer 1.0 AboutContainer.qml
|
||||
SignoutContainer 1.0 SignoutContainer.qml
|
||||
BackupSeedModal 1.0 BackupSeedModal.qml
|
||||
LanguageModal 1.0 LanguageModal.qml
|
||||
|
|
|
@ -93,16 +93,10 @@ Button {
|
|||
visible: !loadingIndicator.active
|
||||
}
|
||||
|
||||
|
||||
Component {
|
||||
id: loadingComponent
|
||||
StatusLoadingIndicator {}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loadingIndicator
|
||||
active: control.state === "pending"
|
||||
sourceComponent: loadingComponent
|
||||
sourceComponent: StatusLoadingIndicator {}
|
||||
height: loadingIndicator.visible ?
|
||||
control.size === "large" ?
|
||||
23 : 17
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f4463f3955a96e162e9881b73ba02f819e0374a4
|
||||
Subproject commit 253e673e5ed8cda01fde9d9a6f21bff688a06d74
|
Loading…
Reference in New Issue