fix: Manual login after local pairing (#10858)
This commit is contained in:
parent
7eed470829
commit
e82f6ebf53
|
@ -9,7 +9,7 @@ type LocalPairingSignal* = ref object of Signal
|
||||||
eventType*: EventType
|
eventType*: EventType
|
||||||
action*: Action
|
action*: Action
|
||||||
error*: string
|
error*: string
|
||||||
account*: AccountDto
|
accountData*: LocalPairingAccountData
|
||||||
installation*: InstallationDto
|
installation*: InstallationDto
|
||||||
|
|
||||||
proc fromEvent*(T: type LocalPairingSignal, event: JsonNode): LocalPairingSignal =
|
proc fromEvent*(T: type LocalPairingSignal, event: JsonNode): LocalPairingSignal =
|
||||||
|
@ -26,7 +26,7 @@ proc fromEvent*(T: type LocalPairingSignal, event: JsonNode): LocalPairingSignal
|
||||||
return
|
return
|
||||||
case result.eventType:
|
case result.eventType:
|
||||||
of EventReceivedAccount:
|
of EventReceivedAccount:
|
||||||
result.account = e["data"].toAccountDto()
|
result.accountData = e["data"].toLocalPairingAccountData()
|
||||||
of EventReceivedInstallation:
|
of EventReceivedInstallation:
|
||||||
result.installation = e["data"].toInstallationDto()
|
result.installation = e["data"].toInstallationDto()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -56,6 +56,7 @@ type
|
||||||
tmpKeychainErrorOccurred: bool
|
tmpKeychainErrorOccurred: bool
|
||||||
tmpRecoverUsingSeedPhraseWhileLogin: bool
|
tmpRecoverUsingSeedPhraseWhileLogin: bool
|
||||||
tmpConnectionString: string
|
tmpConnectionString: string
|
||||||
|
localPairingStatus: LocalPairingStatus
|
||||||
|
|
||||||
proc newController*(delegate: io_interface.AccessInterface,
|
proc newController*(delegate: io_interface.AccessInterface,
|
||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
|
@ -167,8 +168,8 @@ proc init*(self: Controller) =
|
||||||
self.connectionIds.add(handlerId)
|
self.connectionIds.add(handlerId)
|
||||||
|
|
||||||
handlerId = self.events.onWithUUID(SIGNAL_LOCAL_PAIRING_STATUS_UPDATE) do(e: Args):
|
handlerId = self.events.onWithUUID(SIGNAL_LOCAL_PAIRING_STATUS_UPDATE) do(e: Args):
|
||||||
let args = LocalPairingStatus(e)
|
self.localPairingStatus = LocalPairingStatus(e)
|
||||||
self.delegate.onLocalPairingStatusUpdate(args)
|
self.delegate.onLocalPairingStatusUpdate(self.localPairingStatus)
|
||||||
self.connectionIds.add(handlerId)
|
self.connectionIds.add(handlerId)
|
||||||
|
|
||||||
handlerId = self.events.onWithUUID(SIGNAL_REENCRYPTION_PROCESS_STARTED) do(e: Args):
|
handlerId = self.events.onWithUUID(SIGNAL_REENCRYPTION_PROCESS_STARTED) do(e: Args):
|
||||||
|
@ -447,6 +448,10 @@ proc login*(self: Controller) =
|
||||||
let selectedAccount = self.getSelectedLoginAccount()
|
let selectedAccount = self.getSelectedLoginAccount()
|
||||||
self.accountsService.login(selectedAccount, hashPassword(self.tmpPassword))
|
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) =
|
proc loginAccountKeycard*(self: Controller, storeToKeychainValue: string, syncWalletAfterLogin = false) =
|
||||||
if syncWalletAfterLogin:
|
if syncWalletAfterLogin:
|
||||||
self.syncKeycardBasedOnAppWalletStateAfterLogin()
|
self.syncKeycardBasedOnAppWalletStateAfterLogin()
|
||||||
|
|
|
@ -9,4 +9,4 @@ proc delete*(self: SyncDeviceResultState) =
|
||||||
self.State.delete
|
self.State.delete
|
||||||
|
|
||||||
method executePrimaryCommand*(self: SyncDeviceResultState, controller: Controller) =
|
method executePrimaryCommand*(self: SyncDeviceResultState, controller: Controller) =
|
||||||
controller.login()
|
controller.loginLocalPairingAccount()
|
||||||
|
|
|
@ -195,4 +195,4 @@ type
|
||||||
c.storeDefaultKeyPairForNewKeycardUser()
|
c.storeDefaultKeyPairForNewKeycardUser()
|
||||||
c.syncKeycardBasedOnAppWalletStateAfterLogin()
|
c.syncKeycardBasedOnAppWalletStateAfterLogin()
|
||||||
c.addToKeycardUidPairsToCheckForAChangeAfterLogin(string, string)
|
c.addToKeycardUidPairsToCheckForAChangeAfterLogin(string, string)
|
||||||
c.removeAllKeycardUidPairsForCheckingForAChangeAfterLogin()
|
c.removeAllKeycardUidPairsForCheckingForAChangeAfterLogin()
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import json
|
||||||
|
include ../../../common/[json_utils]
|
||||||
import ../../../../app/core/eventemitter
|
import ../../../../app/core/eventemitter
|
||||||
import ../../accounts/dto/accounts
|
import ../../accounts/dto/accounts
|
||||||
import installation
|
import installation
|
||||||
|
@ -22,12 +24,17 @@ type
|
||||||
ActionSyncDevice = 3,
|
ActionSyncDevice = 3,
|
||||||
ActionPairingInstallation = 4,
|
ActionPairingInstallation = 4,
|
||||||
|
|
||||||
|
type
|
||||||
|
LocalPairingAccountData* = ref object
|
||||||
|
account*: AccountDTO
|
||||||
|
password*: string
|
||||||
|
|
||||||
type
|
type
|
||||||
LocalPairingEventArgs* = ref object of Args
|
LocalPairingEventArgs* = ref object of Args
|
||||||
eventType*: EventType
|
eventType*: EventType
|
||||||
action*: Action
|
action*: Action
|
||||||
error*: string
|
error*: string
|
||||||
account*: AccountDTO
|
accountData*: LocalPairingAccountData
|
||||||
installation*: InstallationDto
|
installation*: InstallationDto
|
||||||
|
|
||||||
proc parse*(self: string): EventType =
|
proc parse*(self: string): EventType =
|
||||||
|
@ -63,3 +70,12 @@ proc parse*(self: int): Action =
|
||||||
return ActionPairingInstallation
|
return ActionPairingInstallation
|
||||||
else:
|
else:
|
||||||
return ActionUnknown
|
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)
|
||||||
|
|
|
@ -21,6 +21,7 @@ type
|
||||||
mode*: LocalPairingMode
|
mode*: LocalPairingMode
|
||||||
state*: LocalPairingState
|
state*: LocalPairingState
|
||||||
account*: AccountDTO
|
account*: AccountDTO
|
||||||
|
password*: string
|
||||||
installation*: InstallationDto
|
installation*: InstallationDto
|
||||||
error*: string
|
error*: string
|
||||||
|
|
||||||
|
@ -47,7 +48,8 @@ proc update*(self: LocalPairingStatus, data: LocalPairingEventArgs) =
|
||||||
# process any incoming data
|
# process any incoming data
|
||||||
case data.eventType:
|
case data.eventType:
|
||||||
of EventReceivedAccount:
|
of EventReceivedAccount:
|
||||||
self.account = data.account
|
self.account = data.accountData.account
|
||||||
|
self.password = data.accountData.password
|
||||||
of EventReceivedInstallation:
|
of EventReceivedInstallation:
|
||||||
self.installation = data.installation
|
self.installation = data.installation
|
||||||
of EventConnectionError:
|
of EventConnectionError:
|
||||||
|
|
|
@ -92,7 +92,7 @@ QtObject:
|
||||||
let data = LocalPairingEventArgs(
|
let data = LocalPairingEventArgs(
|
||||||
eventType: signalData.eventType,
|
eventType: signalData.eventType,
|
||||||
action: signalData.action,
|
action: signalData.action,
|
||||||
account: signalData.account,
|
accountData: signalData.accountData,
|
||||||
installation: signalData.installation,
|
installation: signalData.installation,
|
||||||
error: signalData.error)
|
error: signalData.error)
|
||||||
self.updateLocalPairingStatus(data)
|
self.updateLocalPairingStatus(data)
|
||||||
|
@ -169,7 +169,7 @@ QtObject:
|
||||||
let data = LocalPairingEventArgs(
|
let data = LocalPairingEventArgs(
|
||||||
eventType: EventConnectionError,
|
eventType: EventConnectionError,
|
||||||
action: ActionUnknown,
|
action: ActionUnknown,
|
||||||
account: AccountDto(),
|
accountData: LocalPairingAccountData(),
|
||||||
error: errorDescription)
|
error: errorDescription)
|
||||||
self.updateLocalPairingStatus(data)
|
self.updateLocalPairingStatus(data)
|
||||||
|
|
||||||
|
|
|
@ -60,16 +60,14 @@ Item {
|
||||||
text: qsTr("Sign in")
|
text: qsTr("Sign in")
|
||||||
opacity: d.finished ? 1 : 0
|
opacity: d.finished ? 1 : 0
|
||||||
enabled: d.finished
|
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 {
|
Behavior on opacity {
|
||||||
NumberAnimation { duration: 250 }
|
NumberAnimation { duration: 250 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
root.startupStore.doPrimaryAction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 790efc16aa2787b7afc9be2b09116055eb75fc1f
|
Subproject commit a7df4ed388e4d78653326ed7a35e72221e23a5d9
|
Loading…
Reference in New Issue