fix(@desktop/settings): Store pass to keychain does not validate current password which results to inability to login

fixes #4358
This commit is contained in:
Khushboo-dev-cpp 2022-02-24 13:18:21 +01:00 committed by Iuri Matias
parent 343ce69e29
commit dcac7977d9
11 changed files with 56 additions and 4 deletions

View File

@ -57,3 +57,6 @@ method getMessagesFromContactsOnly*(self: Controller): bool =
method setMessagesFromContactsOnly*(self: Controller, value: bool): bool = method setMessagesFromContactsOnly*(self: Controller, value: bool): bool =
return self.settingsService.saveMessagesFromContactsOnly(value) return self.settingsService.saveMessagesFromContactsOnly(value)
method validatePassword*(self: Controller, password: string): bool =
return self.privacyService.validatePassword(password)

View File

@ -31,3 +31,6 @@ method getMessagesFromContactsOnly*(self: AccessInterface): bool {.base.} =
method setMessagesFromContactsOnly*(self: AccessInterface, value: bool): bool {.base.} = method setMessagesFromContactsOnly*(self: AccessInterface, value: bool): bool {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method validatePassword*(self: AccessInterface, password: string): bool {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -52,3 +52,6 @@ method getMessagesFromContactsOnly*(self: AccessInterface): bool {.base.} =
method setMessagesFromContactsOnly*(self: AccessInterface, value: bool) {.base.} = method setMessagesFromContactsOnly*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method validatePassword*(self: AccessInterface, password: string): bool {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -75,3 +75,6 @@ method getMessagesFromContactsOnly*(self: Module): bool =
method setMessagesFromContactsOnly*(self: Module, value: bool) = method setMessagesFromContactsOnly*(self: Module, value: bool) =
if(not self.controller.setMessagesFromContactsOnly(value)): if(not self.controller.setMessagesFromContactsOnly(value)):
error "an error occurred while saving messages from contacts only flag" error "an error occurred while saving messages from contacts only flag"
method validatePassword*(self: Module, password: string): bool =
self.controller.validatePassword(password)

View File

@ -57,3 +57,6 @@ QtObject:
read = getMessagesFromContactsOnly read = getMessagesFromContactsOnly
write = setMessagesFromContactsOnly write = setMessagesFromContactsOnly
notify = messagesFromContactsOnlyChanged notify = messagesFromContactsOnlyChanged
proc validatePassword*(self: View, password: string): bool {.slot.} =
self.delegate.validatePassword(password)

View File

@ -130,3 +130,21 @@ QtObject:
return return
return mnemonics[index] return mnemonics[index]
proc validatePassword*(self: Service, password: string): bool =
try:
let defaultAccount = self.getDefaultAccount()
if(defaultAccount.len == 0):
error "error: ", methodName="validatePassword", errDesription = "default eth account is empty"
return false
let isPasswordOk = self.accountsService.verifyAccountPassword(defaultAccount, password)
if not isPasswordOk:
error "error: ", methodName="validatePassword", errDesription = "password cannnot be verified"
return false
return true
except Exception as e:
error "error: ", methodName="validatePassword", errName = e.name, errDesription = e.msg
return false

View File

@ -12,6 +12,7 @@ import shared.controls 1.0
// TODO: replace with StatusModal // TODO: replace with StatusModal
ModalPopup { ModalPopup {
property var privacyStore
property bool loading: false property bool loading: false
property bool firstPasswordFieldValid: false property bool firstPasswordFieldValid: false
property bool repeatPasswordFieldValid: false property bool repeatPasswordFieldValid: false
@ -45,6 +46,8 @@ ModalPopup {
onTextChanged: { onTextChanged: {
[firstPasswordFieldValid, passwordValidationError] = [firstPasswordFieldValid, passwordValidationError] =
Utils.validatePasswords("first", firstPasswordField, repeatPasswordField); Utils.validatePasswords("first", firstPasswordField, repeatPasswordField);
[repeatPasswordFieldValid, repeatPasswordValidationError] =
Utils.validatePasswords("repeat", firstPasswordField, repeatPasswordField);
} }
} }
@ -159,8 +162,16 @@ ModalPopup {
onClicked: { onClicked: {
if (storingPasswordModal) if (storingPasswordModal)
{ {
Global.applicationWindow.prepareForStoring(repeatPasswordField.text, true) // validate the entered password
popup.close() var validatePassword = privacyStore.validatePassword(repeatPasswordField.text)
if(!validatePassword) {
firstPasswordFieldValid = false
passwordValidationError = qsTr("Incorrect password")
}
else {
Global.applicationWindow.prepareForStoring(repeatPasswordField.text, true)
popup.close()
}
} }
else else
{ {

View File

@ -39,7 +39,6 @@ Item {
if(localAccountSettings.storeToKeychainValue === Constants.storeToKeychainValueStore) if(localAccountSettings.storeToKeychainValue === Constants.storeToKeychainValueStore)
{ {
connection.enabled = true connection.enabled = true
txtPassword.visible = false
} }
else else
{ {

View File

@ -12,6 +12,8 @@ import "../../Onboarding/shared" as OnboardingComponents
ModalPopup { ModalPopup {
id: popup id: popup
property var privacyStore
title: qsTr("Store pass to Keychain") title: qsTr("Store pass to Keychain")
onClosed: { onClosed: {
@ -95,6 +97,7 @@ ModalPopup {
Component { Component {
id: storePasswordModal id: storePasswordModal
OnboardingComponents.CreatePasswordModal { OnboardingComponents.CreatePasswordModal {
privacyStore: popup.privacyStore
storingPasswordModal: true storingPasswordModal: true
height: 350 height: 350
} }

View File

@ -28,4 +28,8 @@ QtObject {
function getMnemonicWordAtIndex(index) { function getMnemonicWordAtIndex(index) {
return root.privacyModule.getMnemonicWordAtIndex(index) return root.privacyModule.getMnemonicWordAtIndex(index)
} }
function validatePassword(password) {
return root.privacyModule.validatePassword(password)
}
} }

View File

@ -111,7 +111,9 @@ Item {
Component { Component {
id: storeToKeychainSelectionModal id: storeToKeychainSelectionModal
StoreToKeychainSelectionModal {} StoreToKeychainSelectionModal {
privacyStore: root.privacyStore
}
} }
} }