fix(@desktop/sync): settings/mnemonic sync&backup handling

Part of #10389 issue.
This commit is contained in:
Sale Djenic 2023-05-30 19:10:46 +02:00 committed by saledjenic
parent 3d3def9f53
commit ffc059308f
6 changed files with 12 additions and 10 deletions

View File

@ -290,7 +290,7 @@ proc init*(self: Controller) =
var args = TrustArgs(e)
self.delegate.contactUpdated(args.publicKey)
self.events.on(SIGNAL_MNEMONIC_REMOVAL) do(e: Args):
self.events.on(SIGNAL_MNEMONIC_REMOVED) do(e: Args):
self.delegate.mnemonicBackedUp()
self.events.on(SIGNAL_MAKE_SECTION_CHAT_ACTIVE) do(e: Args):

View File

@ -63,8 +63,8 @@ proc init*(self: Controller) =
return
self.delegate.onUserAuthenticated(args.pin, args.password, args.keyUid)
self.events.on(SIGNAL_MNEMONIC_REMOVAL) do(e: Args):
self.delegate.onMnemonicUpdated()
self.events.on(SIGNAL_MNEMONIC_REMOVED) do(e: Args):
self.delegate.mnemonicBackedUp()
self.events.on(SIGNAL_PASSWORD_CHANGED) do(e: Args):
var args = OperationSuccessArgs(e)
@ -97,7 +97,7 @@ proc setMessagesFromContactsOnly*(self: Controller, value: bool): bool =
proc validatePassword*(self: Controller, password: string): bool =
return self.privacyService.validatePassword(password)
method getPasswordStrengthScore*(self: Controller, password, userName: string): int =
method getPasswordStrengthScore*(self: Controller, password, userName: string): int =
return self.generalService.getPasswordStrengthScore(password, userName)
proc storeToKeychain*(self: Controller, data: string) =

View File

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

View File

@ -66,7 +66,7 @@ method changePassword*(self: Module, password: string, newPassword: string) =
method isMnemonicBackedUp*(self: Module): bool =
return self.controller.isMnemonicBackedUp()
method onMnemonicUpdated*(self: Module) =
method mnemonicBackedUp*(self: Module) =
self.view.emitMnemonicBackedUpSignal()
method onPasswordChanged*(self: Module, success: bool, errorMsg: string) =
@ -97,7 +97,7 @@ method getPasswordStrengthScore*(self: Module, password: string): int =
method onStoreToKeychainError*(self: Module, errorDescription: string, errorType: string) =
self.view.emitStoreToKeychainError(errorDescription)
method onStoreToKeychainSuccess*(self: Module, data: string) =
method onStoreToKeychainSuccess*(self: Module, data: string) =
if self.keychainActivityReason == KeychainActivityReason.StoreTo:
singletonInstance.localAccountSettings.setStoreToKeychainValue(LS_VALUE_STORE)
elif self.keychainActivityReason == KeychainActivityReason.RemoveFrom:

View File

@ -13,7 +13,6 @@ logScope:
topics = "privacy-service"
# Signals which may be emitted by this service:
const SIGNAL_MNEMONIC_REMOVAL* = "menmonicRemoval"
const SIGNAL_PASSWORD_CHANGED* = "passwordChanged"
type
@ -116,8 +115,6 @@ QtObject:
data.success = false
error "error: ", procName="removeMnemonic", errDesription = "an error occurred removing mnemonic"
self.events.emit(SIGNAL_MNEMONIC_REMOVAL, data)
proc getMnemonicWordAtIndex*(self: Service, index: int): string =
let mnemonic = self.settingsService.getMnemonic()
if(mnemonic.len == 0):

View File

@ -24,6 +24,7 @@ const DEFAULT_FLEET* = $Fleet.StatusProd
const SIGNAL_CURRENCY_UPDATED* = "currencyUpdated"
const SIGNAL_DISPLAY_NAME_UPDATED* = "displayNameUpdated"
const SIGNAL_BIO_UPDATED* = "bioUpdated"
const SIGNAL_MNEMONIC_REMOVED* = "mnemonicRemoved"
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
logScope:
@ -98,6 +99,9 @@ QtObject:
if settingsField.name == KEY_BIO:
self.settings.bio = settingsField.value
self.events.emit(SIGNAL_BIO_UPDATED, SettingsTextValueArgs(value: settingsField.value))
if settingsField.name == KEY_MNEMONIC:
self.settings.mnemonic = ""
self.events.emit(SIGNAL_MNEMONIC_REMOVED, Args())
self.initialized = true
@ -236,6 +240,7 @@ QtObject:
proc saveMnemonic*(self: Service, value: string): bool =
if(self.saveSetting(KEY_MNEMONIC, value)):
self.settings.mnemonic = value
self.events.emit(SIGNAL_MNEMONIC_REMOVED, Args())
return true
return false