fix(change_pasword): Add error message to change password popup

Closes: #5190
This commit is contained in:
Boris Melnik 2022-03-29 15:42:55 +03:00 committed by Iuri Matias
parent 8e8ffd3b05
commit 1f82a784d1
6 changed files with 14 additions and 10 deletions

View File

@ -35,7 +35,7 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_PASSWORD_CHANGED) do(e: Args): self.events.on(SIGNAL_PASSWORD_CHANGED) do(e: Args):
var args = OperationSuccessArgs(e) var args = OperationSuccessArgs(e)
self.delegate.onPasswordChanged(args.success) self.delegate.onPasswordChanged(args.success, args.errorMsg)
proc isMnemonicBackedUp*(self: Controller): bool = proc isMnemonicBackedUp*(self: Controller): bool =
return self.privacyService.isMnemonicBackedUp() return self.privacyService.isMnemonicBackedUp()
@ -78,3 +78,4 @@ proc setProfilePicturesVisibility*(self: Controller, value: int): bool =
method getPasswordStrengthScore*(self: Controller, password, userName: string): int = method getPasswordStrengthScore*(self: Controller, password, userName: string): int =
return self.generalService.getPasswordStrengthScore(password, userName) return self.generalService.getPasswordStrengthScore(password, userName)

View File

@ -44,7 +44,7 @@ method getMnemonicWordAtIndex*(self: AccessInterface, index: int): string {.base
method onMnemonicUpdated*(self: AccessInterface) {.base.} = method onMnemonicUpdated*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method onPasswordChanged*(self: AccessInterface, success: bool) {.base.} = method onPasswordChanged*(self: AccessInterface, success: bool, errorMsg: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getMessagesFromContactsOnly*(self: AccessInterface): bool {.base.} = method getMessagesFromContactsOnly*(self: AccessInterface): bool {.base.} =

View File

@ -61,8 +61,8 @@ method isMnemonicBackedUp*(self: Module): bool =
method onMnemonicUpdated*(self: Module) = method onMnemonicUpdated*(self: Module) =
self.view.emitMnemonicBackedUpSignal() self.view.emitMnemonicBackedUpSignal()
method onPasswordChanged*(self: Module, success: bool) = method onPasswordChanged*(self: Module, success: bool, errorMsg: string) =
self.view.emitPasswordChangedSignal(success) self.view.emitPasswordChangedSignal(success, errorMsg)
method getMnemonic*(self: Module): string = method getMnemonic*(self: Module): string =
self.controller.getMnemonic() self.controller.getMnemonic()

View File

@ -24,9 +24,9 @@ QtObject:
proc changePassword*(self: View, password: string, newPassword: string) {.slot.} = proc changePassword*(self: View, password: string, newPassword: string) {.slot.} =
self.delegate.changePassword(password, newPassword) self.delegate.changePassword(password, newPassword)
proc passwordChanged(self: View, success: bool) {.signal.} proc passwordChanged(self: View, success: bool, errorMsg: string) {.signal.}
proc emitPasswordChangedSignal*(self: View, success: bool) = proc emitPasswordChangedSignal*(self: View, success: bool, errorMsg: string) =
self.passwordChanged(success) self.passwordChanged(success, errorMsg)
proc mnemonicBackedUpChanged(self: View) {.signal.} proc mnemonicBackedUpChanged(self: View) {.signal.}
proc isMnemonicBackedUp(self: View): bool {.slot.} = proc isMnemonicBackedUp(self: View): bool {.slot.} =

View File

@ -20,6 +20,7 @@ const SIGNAL_PASSWORD_CHANGED* = "passwordChanged"
type type
OperationSuccessArgs* = ref object of Args OperationSuccessArgs* = ref object of Args
success*: bool success*: bool
errorMsg*: string
QtObject: QtObject:
type Service* = ref object of QObject type Service* = ref object of QObject
@ -74,7 +75,7 @@ QtObject:
proc changePassword*(self: Service, password: string, newPassword: string) = proc changePassword*(self: Service, password: string, newPassword: string) =
try: try:
var data = OperationSuccessArgs(success: false) var data = OperationSuccessArgs(success: false, errorMsg: "")
let defaultAccount = self.getDefaultAccount() let defaultAccount = self.getDefaultAccount()
if(defaultAccount.len == 0): if(defaultAccount.len == 0):
@ -84,6 +85,7 @@ QtObject:
let isPasswordOk = self.accountsService.verifyAccountPassword(defaultAccount, password) let isPasswordOk = self.accountsService.verifyAccountPassword(defaultAccount, password)
if not isPasswordOk: if not isPasswordOk:
data.errorMsg = "Incorrect current password"
error "error: ", procName="changePassword", errDesription = "password cannnot be verified" error "error: ", procName="changePassword", errDesription = "password cannnot be verified"
self.events.emit(SIGNAL_PASSWORD_CHANGED, data) self.events.emit(SIGNAL_PASSWORD_CHANGED, data)
return return

View File

@ -21,12 +21,13 @@ StatusModal {
property var privacyStore property var privacyStore
signal passwordChanged() signal passwordChanged()
function onChangePasswordResponse(success) { function onChangePasswordResponse(success, errorMsg) {
if (success) { if (success) {
passwordChanged() passwordChanged()
submitBtn.enabled = false submitBtn.enabled = false
} else { } else {
view.reset() view.reset()
view.errorMsgText = errorMsg
console.warn("TODO: Display error message when change password action failure! ") console.warn("TODO: Display error message when change password action failure! ")
} }
submitBtn.loading = false submitBtn.loading = false
@ -34,7 +35,7 @@ StatusModal {
Connections { Connections {
target: root.privacyStore.privacyModule target: root.privacyStore.privacyModule
onPasswordChanged: onChangePasswordResponse(success) onPasswordChanged: onChangePasswordResponse(success, errorMsg)
} }
width: 480 width: 480