fix: Manual login after local pairing (#10858)

This commit is contained in:
Igor Sirotin 2023-06-01 11:15:51 +03:00 committed by GitHub
parent 7eed470829
commit e82f6ebf53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 18 deletions

View File

@ -9,7 +9,7 @@ type LocalPairingSignal* = ref object of Signal
eventType*: EventType
action*: Action
error*: string
account*: AccountDto
accountData*: LocalPairingAccountData
installation*: InstallationDto
proc fromEvent*(T: type LocalPairingSignal, event: JsonNode): LocalPairingSignal =
@ -26,7 +26,7 @@ proc fromEvent*(T: type LocalPairingSignal, event: JsonNode): LocalPairingSignal
return
case result.eventType:
of EventReceivedAccount:
result.account = e["data"].toAccountDto()
result.accountData = e["data"].toLocalPairingAccountData()
of EventReceivedInstallation:
result.installation = e["data"].toInstallationDto()
else:

View File

@ -56,6 +56,7 @@ type
tmpKeychainErrorOccurred: bool
tmpRecoverUsingSeedPhraseWhileLogin: bool
tmpConnectionString: string
localPairingStatus: LocalPairingStatus
proc newController*(delegate: io_interface.AccessInterface,
events: EventEmitter,
@ -167,8 +168,8 @@ proc init*(self: Controller) =
self.connectionIds.add(handlerId)
handlerId = self.events.onWithUUID(SIGNAL_LOCAL_PAIRING_STATUS_UPDATE) do(e: Args):
let args = LocalPairingStatus(e)
self.delegate.onLocalPairingStatusUpdate(args)
self.localPairingStatus = LocalPairingStatus(e)
self.delegate.onLocalPairingStatusUpdate(self.localPairingStatus)
self.connectionIds.add(handlerId)
handlerId = self.events.onWithUUID(SIGNAL_REENCRYPTION_PROCESS_STARTED) do(e: Args):
@ -447,6 +448,10 @@ proc login*(self: Controller) =
let selectedAccount = self.getSelectedLoginAccount()
self.accountsService.login(selectedAccount, hashPassword(self.tmpPassword))
proc loginLocalPairingAccount*(self: Controller) =
self.delegate.moveToLoadingAppState()
self.accountsService.login(self.localPairingStatus.account, self.localPairingStatus.password)
proc loginAccountKeycard*(self: Controller, storeToKeychainValue: string, syncWalletAfterLogin = false) =
if syncWalletAfterLogin:
self.syncKeycardBasedOnAppWalletStateAfterLogin()

View File

@ -9,4 +9,4 @@ proc delete*(self: SyncDeviceResultState) =
self.State.delete
method executePrimaryCommand*(self: SyncDeviceResultState, controller: Controller) =
controller.login()
controller.loginLocalPairingAccount()

View File

@ -195,4 +195,4 @@ type
c.storeDefaultKeyPairForNewKeycardUser()
c.syncKeycardBasedOnAppWalletStateAfterLogin()
c.addToKeycardUidPairsToCheckForAChangeAfterLogin(string, string)
c.removeAllKeycardUidPairsForCheckingForAChangeAfterLogin()
c.removeAllKeycardUidPairsForCheckingForAChangeAfterLogin()

View File

@ -1,3 +1,5 @@
import json
include ../../../common/[json_utils]
import ../../../../app/core/eventemitter
import ../../accounts/dto/accounts
import installation
@ -22,12 +24,17 @@ type
ActionSyncDevice = 3,
ActionPairingInstallation = 4,
type
LocalPairingAccountData* = ref object
account*: AccountDTO
password*: string
type
LocalPairingEventArgs* = ref object of Args
eventType*: EventType
action*: Action
error*: string
account*: AccountDTO
accountData*: LocalPairingAccountData
installation*: InstallationDto
proc parse*(self: string): EventType =
@ -63,3 +70,12 @@ proc parse*(self: int): Action =
return ActionPairingInstallation
else:
return ActionUnknown
proc toLocalPairingAccountData*(jsonObj: JsonNode): LocalPairingAccountData =
result = LocalPairingAccountData()
discard jsonObj.getProp("password", result.password)
var accountObj: JsonNode
if(jsonObj.getProp("account", accountObj)):
result.account = toAccountDto(accountObj)

View File

@ -21,6 +21,7 @@ type
mode*: LocalPairingMode
state*: LocalPairingState
account*: AccountDTO
password*: string
installation*: InstallationDto
error*: string
@ -47,7 +48,8 @@ proc update*(self: LocalPairingStatus, data: LocalPairingEventArgs) =
# process any incoming data
case data.eventType:
of EventReceivedAccount:
self.account = data.account
self.account = data.accountData.account
self.password = data.accountData.password
of EventReceivedInstallation:
self.installation = data.installation
of EventConnectionError:

View File

@ -92,7 +92,7 @@ QtObject:
let data = LocalPairingEventArgs(
eventType: signalData.eventType,
action: signalData.action,
account: signalData.account,
accountData: signalData.accountData,
installation: signalData.installation,
error: signalData.error)
self.updateLocalPairingStatus(data)
@ -169,7 +169,7 @@ QtObject:
let data = LocalPairingEventArgs(
eventType: EventConnectionError,
action: ActionUnknown,
account: AccountDto(),
accountData: LocalPairingAccountData(),
error: errorDescription)
self.updateLocalPairingStatus(data)

View File

@ -60,16 +60,14 @@ Item {
text: qsTr("Sign in")
opacity: d.finished ? 1 : 0
enabled: d.finished
onClicked: {
// NOTE: Current status-go implementation automatically signs in
// So we don't actually ever use this button.
// I leave this code here for further implementaion by design.
//const keyUid = "TODO: Get keyUid somehow"
//root.startupStore.setSelectedLoginAccountByKeyUid(keyUid)
}
Behavior on opacity {
NumberAnimation { duration: 250 }
}
onClicked: {
root.startupStore.doPrimaryAction()
}
}
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 790efc16aa2787b7afc9be2b09116055eb75fc1f
Subproject commit a7df4ed388e4d78653326ed7a35e72221e23a5d9