diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 8e9de3c48e..b10b8e988c 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -485,12 +485,6 @@ proc appReady*(self: AppController) = proc finishAppLoading*(self: AppController) = self.load() - # Once user is logged in and main module is loaded we need to check if it gets here importing mnemonic or not - # and delete mnemonic in the first case. - let importedAccount = self.accountsService.getImportedAccount() - if(importedAccount.isValid()): - self.privacyService.removeMnemonic() - if not self.startupModule.isNil: self.startupModule.onAppLoaded() self.startupModule = nil diff --git a/src/app/modules/startup/controller.nim b/src/app/modules/startup/controller.nim index 9b2db6e795..f7a987990c 100644 --- a/src/app/modules/startup/controller.nim +++ b/src/app/modules/startup/controller.nim @@ -380,9 +380,9 @@ proc setupKeychain(self: Controller, store: bool) = else: singletonInstance.localAccountSettings.setStoreToKeychainValue(LS_VALUE_NEVER) -proc setupAccount(self: Controller, accountId: string, storeToKeychain: bool, recoverAccount: bool = false) = +proc setupAccount(self: Controller, accountId: string, removeMnemonic: bool, storeToKeychain: bool, recoverAccount: bool = false) = self.delegate.moveToLoadingAppState() - let error = self.accountsService.setupAccount(accountId, self.tmpPassword, self.tmpDisplayName, recoverAccount) + let error = self.accountsService.setupAccount(accountId, self.tmpPassword, self.tmpDisplayName, removeMnemonic, recoverAccount) if error != "": self.delegate.emitStartupError(error, StartupErrorType.SetupAccError) else: @@ -394,11 +394,11 @@ proc storeGeneratedAccountAndLogin*(self: Controller, storeToKeychain: bool) = error "list of generated accounts is empty" return let accountId = accounts[0].id - self.setupAccount(accountId, storeToKeychain) + self.setupAccount(accountId, removeMnemonic=false, storeToKeychain) proc storeImportedAccountAndLogin*(self: Controller, storeToKeychain: bool, recoverAccount: bool = false) = let accountId = self.getImportedAccount().id - self.setupAccount(accountId, storeToKeychain, recoverAccount) + self.setupAccount(accountId, removeMnemonic=true, storeToKeychain, recoverAccount) proc storeKeycardAccountAndLogin*(self: Controller, storeToKeychain: bool, newKeycard: bool) = if self.importMnemonic(): diff --git a/src/app_service/service/accounts/service.nim b/src/app_service/service/accounts/service.nim index 3c7a9cc606..d698c13a6d 100644 --- a/src/app_service/service/accounts/service.nim +++ b/src/app_service/service/accounts/service.nim @@ -269,10 +269,10 @@ QtObject: return logLevel proc prepareAccountSettingsJsonObject(self: Service, account: GeneratedAccountDto, - installationId: string, displayName: string): JsonNode = + installationId: string, displayName: string, withoutMnemonic: bool): JsonNode = result = %* { "key-uid": account.keyUid, - "mnemonic": account.mnemonic, + "mnemonic": if withoutMnemonic: "" else: account.mnemonic, "public-key": account.derivedAccounts.whisper.publicKey, "name": account.alias, "display-name": displayName, @@ -302,16 +302,14 @@ QtObject: "url-unfurling-mode": int(settings.UrlUnfurlingMode.AlwaysAsk), } - proc getAccountSettings(self: Service, accountId: string, - installationId: string, - displayName: string): JsonNode = + proc getAccountSettings(self: Service, accountId: string, installationId: string, displayName: string, withoutMnemonic: bool): JsonNode = for acc in self.generatedAccounts: if(acc.id == accountId): - return self.prepareAccountSettingsJsonObject(acc, installationId, displayName) + return self.prepareAccountSettingsJsonObject(acc, installationId, displayName, withoutMnemonic) if(self.importedAccount.isValid()): if(self.importedAccount.id == accountId): - return self.prepareAccountSettingsJsonObject(self.importedAccount, installationId, displayName) + return self.prepareAccountSettingsJsonObject(self.importedAccount, installationId, displayName, withoutMnemonic) proc getDefaultNodeConfig*(self: Service, installationId: string, recoverAccount: bool): JsonNode = let fleet = Fleet.ShardsTest @@ -430,13 +428,13 @@ QtObject: if not accountData.isNil: accountData["keycard-pairing"] = kcDataObj{"key"} - proc setupAccount*(self: Service, accountId, password, displayName: string, recoverAccount: bool = false): string = + proc setupAccount*(self: Service, accountId, password, displayName: string, removeMnemonic: bool, recoverAccount: bool = false): string = try: let installationId = $genUUID() var accountDataJson = self.getAccountDataForAccountId(accountId, displayName) self.setKeyStoreDir(accountDataJson{"key-uid"}.getStr) # must be called before `getDefaultNodeConfig` let subaccountDataJson = self.getSubaccountDataForAccountId(accountId, displayName) - var settingsJson = self.getAccountSettings(accountId, installationId, displayName) + var settingsJson = self.getAccountSettings(accountId, installationId, displayName, removeMnemonic) let nodeConfigJson = self.getDefaultNodeConfig(installationId, recoverAccount) if(accountDataJson.isNil or subaccountDataJson.isNil or settingsJson.isNil or