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):
var args = OperationSuccessArgs(e)
self.delegate.onPasswordChanged(args.success)
self.delegate.onPasswordChanged(args.success, args.errorMsg)
proc isMnemonicBackedUp*(self: Controller): bool =
return self.privacyService.isMnemonicBackedUp()
@ -78,3 +78,4 @@ proc setProfilePicturesVisibility*(self: Controller, value: int): bool =
method getPasswordStrengthScore*(self: Controller, password, userName: string): int =
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.} =
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")
method getMessagesFromContactsOnly*(self: AccessInterface): bool {.base.} =

View File

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

View File

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

View File

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

View File

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