parent
e51667911d
commit
daecb836ac
|
@ -485,12 +485,6 @@ proc appReady*(self: AppController) =
|
||||||
proc finishAppLoading*(self: AppController) =
|
proc finishAppLoading*(self: AppController) =
|
||||||
self.load()
|
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:
|
if not self.startupModule.isNil:
|
||||||
self.startupModule.onAppLoaded()
|
self.startupModule.onAppLoaded()
|
||||||
self.startupModule = nil
|
self.startupModule = nil
|
||||||
|
|
|
@ -380,9 +380,9 @@ proc setupKeychain(self: Controller, store: bool) =
|
||||||
else:
|
else:
|
||||||
singletonInstance.localAccountSettings.setStoreToKeychainValue(LS_VALUE_NEVER)
|
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()
|
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 != "":
|
if error != "":
|
||||||
self.delegate.emitStartupError(error, StartupErrorType.SetupAccError)
|
self.delegate.emitStartupError(error, StartupErrorType.SetupAccError)
|
||||||
else:
|
else:
|
||||||
|
@ -394,11 +394,11 @@ proc storeGeneratedAccountAndLogin*(self: Controller, storeToKeychain: bool) =
|
||||||
error "list of generated accounts is empty"
|
error "list of generated accounts is empty"
|
||||||
return
|
return
|
||||||
let accountId = accounts[0].id
|
let accountId = accounts[0].id
|
||||||
self.setupAccount(accountId, storeToKeychain)
|
self.setupAccount(accountId, removeMnemonic=false, storeToKeychain)
|
||||||
|
|
||||||
proc storeImportedAccountAndLogin*(self: Controller, storeToKeychain: bool, recoverAccount: bool = false) =
|
proc storeImportedAccountAndLogin*(self: Controller, storeToKeychain: bool, recoverAccount: bool = false) =
|
||||||
let accountId = self.getImportedAccount().id
|
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) =
|
proc storeKeycardAccountAndLogin*(self: Controller, storeToKeychain: bool, newKeycard: bool) =
|
||||||
if self.importMnemonic():
|
if self.importMnemonic():
|
||||||
|
|
|
@ -269,10 +269,10 @@ QtObject:
|
||||||
return logLevel
|
return logLevel
|
||||||
|
|
||||||
proc prepareAccountSettingsJsonObject(self: Service, account: GeneratedAccountDto,
|
proc prepareAccountSettingsJsonObject(self: Service, account: GeneratedAccountDto,
|
||||||
installationId: string, displayName: string): JsonNode =
|
installationId: string, displayName: string, withoutMnemonic: bool): JsonNode =
|
||||||
result = %* {
|
result = %* {
|
||||||
"key-uid": account.keyUid,
|
"key-uid": account.keyUid,
|
||||||
"mnemonic": account.mnemonic,
|
"mnemonic": if withoutMnemonic: "" else: account.mnemonic,
|
||||||
"public-key": account.derivedAccounts.whisper.publicKey,
|
"public-key": account.derivedAccounts.whisper.publicKey,
|
||||||
"name": account.alias,
|
"name": account.alias,
|
||||||
"display-name": displayName,
|
"display-name": displayName,
|
||||||
|
@ -302,16 +302,14 @@ QtObject:
|
||||||
"url-unfurling-mode": int(settings.UrlUnfurlingMode.AlwaysAsk),
|
"url-unfurling-mode": int(settings.UrlUnfurlingMode.AlwaysAsk),
|
||||||
}
|
}
|
||||||
|
|
||||||
proc getAccountSettings(self: Service, accountId: string,
|
proc getAccountSettings(self: Service, accountId: string, installationId: string, displayName: string, withoutMnemonic: bool): JsonNode =
|
||||||
installationId: string,
|
|
||||||
displayName: string): JsonNode =
|
|
||||||
for acc in self.generatedAccounts:
|
for acc in self.generatedAccounts:
|
||||||
if(acc.id == accountId):
|
if(acc.id == accountId):
|
||||||
return self.prepareAccountSettingsJsonObject(acc, installationId, displayName)
|
return self.prepareAccountSettingsJsonObject(acc, installationId, displayName, withoutMnemonic)
|
||||||
|
|
||||||
if(self.importedAccount.isValid()):
|
if(self.importedAccount.isValid()):
|
||||||
if(self.importedAccount.id == accountId):
|
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 =
|
proc getDefaultNodeConfig*(self: Service, installationId: string, recoverAccount: bool): JsonNode =
|
||||||
let fleet = Fleet.ShardsTest
|
let fleet = Fleet.ShardsTest
|
||||||
|
@ -430,13 +428,13 @@ QtObject:
|
||||||
if not accountData.isNil:
|
if not accountData.isNil:
|
||||||
accountData["keycard-pairing"] = kcDataObj{"key"}
|
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:
|
try:
|
||||||
let installationId = $genUUID()
|
let installationId = $genUUID()
|
||||||
var accountDataJson = self.getAccountDataForAccountId(accountId, displayName)
|
var accountDataJson = self.getAccountDataForAccountId(accountId, displayName)
|
||||||
self.setKeyStoreDir(accountDataJson{"key-uid"}.getStr) # must be called before `getDefaultNodeConfig`
|
self.setKeyStoreDir(accountDataJson{"key-uid"}.getStr) # must be called before `getDefaultNodeConfig`
|
||||||
let subaccountDataJson = self.getSubaccountDataForAccountId(accountId, displayName)
|
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)
|
let nodeConfigJson = self.getDefaultNodeConfig(installationId, recoverAccount)
|
||||||
|
|
||||||
if(accountDataJson.isNil or subaccountDataJson.isNil or settingsJson.isNil or
|
if(accountDataJson.isNil or subaccountDataJson.isNil or settingsJson.isNil or
|
||||||
|
|
Loading…
Reference in New Issue