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 =
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.} =
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.} =
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) =
if(not self.controller.setMessagesFromContactsOnly(value)):
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
write = setMessagesFromContactsOnly
notify = messagesFromContactsOnlyChanged
proc validatePassword*(self: View, password: string): bool {.slot.} =
self.delegate.validatePassword(password)

View File

@ -130,3 +130,21 @@ QtObject:
return
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
ModalPopup {
property var privacyStore
property bool loading: false
property bool firstPasswordFieldValid: false
property bool repeatPasswordFieldValid: false
@ -45,6 +46,8 @@ ModalPopup {
onTextChanged: {
[firstPasswordFieldValid, passwordValidationError] =
Utils.validatePasswords("first", firstPasswordField, repeatPasswordField);
[repeatPasswordFieldValid, repeatPasswordValidationError] =
Utils.validatePasswords("repeat", firstPasswordField, repeatPasswordField);
}
}
@ -159,8 +162,16 @@ ModalPopup {
onClicked: {
if (storingPasswordModal)
{
Global.applicationWindow.prepareForStoring(repeatPasswordField.text, true)
popup.close()
// validate the entered password
var validatePassword = privacyStore.validatePassword(repeatPasswordField.text)
if(!validatePassword) {
firstPasswordFieldValid = false
passwordValidationError = qsTr("Incorrect password")
}
else {
Global.applicationWindow.prepareForStoring(repeatPasswordField.text, true)
popup.close()
}
}
else
{

View File

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

View File

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

View File

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

View File

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