mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 12:08:53 +00:00
feat(@desktop/general): try again button added to wrong keycard screen
Closes: #10433
This commit is contained in:
parent
a4a2ca4e9c
commit
f3a6b135a3
@ -199,7 +199,7 @@ proc getGeneratedAccounts*(self: Controller): seq[GeneratedAccountDto] =
|
||||
proc getImportedAccount*(self: Controller): GeneratedAccountDto =
|
||||
return self.accountsService.getImportedAccount()
|
||||
|
||||
proc getPasswordStrengthScore*(self: Controller, password, userName: string): int =
|
||||
proc getPasswordStrengthScore*(self: Controller, password, userName: string): int =
|
||||
return self.generalService.getPasswordStrengthScore(password, userName)
|
||||
|
||||
proc clearImage*(self: Controller) =
|
||||
@ -215,7 +215,7 @@ proc generateImage*(self: Controller, imageUrl: string, aX: int, aY: int, bX: in
|
||||
self.tmpProfileImageDetails = ProfileImageDetails(url: imageUrl, croppedImage: img.uri, x1: aX, y1: aY, x2: bX, y2: bY)
|
||||
return img.uri
|
||||
|
||||
proc fetchWakuMessages*(self: Controller) =
|
||||
proc fetchWakuMessages*(self: Controller) =
|
||||
self.generalService.fetchWakuMessages()
|
||||
|
||||
proc getCroppedProfileImage*(self: Controller): string =
|
||||
@ -295,10 +295,10 @@ proc setMetadataFromKeycard*(self: Controller, cardMetadata: CardMetadata) =
|
||||
proc getMetadataFromKeycard*(self: Controller): CardMetadata =
|
||||
return self.tmpCardMetadata
|
||||
|
||||
proc addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: Controller, oldKeycardUid: string, newKeycardUid: string) =
|
||||
proc addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: Controller, oldKeycardUid: string, newKeycardUid: string) =
|
||||
self.delegate.addToKeycardUidPairsToCheckForAChangeAfterLogin(oldKeycardUid, newKeycardUid)
|
||||
|
||||
proc syncKeycardBasedOnAppWalletStateAfterLogin(self: Controller) =
|
||||
proc syncKeycardBasedOnAppWalletStateAfterLogin(self: Controller) =
|
||||
self.delegate.syncKeycardBasedOnAppWalletStateAfterLogin()
|
||||
|
||||
proc keychainErrorOccurred*(self: Controller): bool =
|
||||
@ -331,7 +331,7 @@ proc tryToObtainDataFromKeychain*(self: Controller) =
|
||||
if not main_constants.IS_MACOS or # This is MacOS only feature
|
||||
value != LS_VALUE_STORE:
|
||||
return
|
||||
self.connectKeychain() # handling the results is done in slots connected in `connectKeychain` proc
|
||||
self.connectKeychain() # handling the results is done in slots connected in `connectKeychain` proc
|
||||
self.tmpKeychainErrorOccurred = false
|
||||
let selectedAccount = self.getSelectedLoginAccount()
|
||||
self.keychainService.tryToObtainData(selectedAccount.keyUid)
|
||||
@ -341,7 +341,7 @@ proc storeIdentityImage*(self: Controller): seq[Image] =
|
||||
return
|
||||
let account = self.accountsService.getLoggedInAccount()
|
||||
let image = singletonInstance.utils.formatImagePath(self.tmpProfileImageDetails.url)
|
||||
result = self.profileService.storeIdentityImage(account.keyUid, image, self.tmpProfileImageDetails.x1,
|
||||
result = self.profileService.storeIdentityImage(account.keyUid, image, self.tmpProfileImageDetails.x1,
|
||||
self.tmpProfileImageDetails.y1, self.tmpProfileImageDetails.x2, self.tmpProfileImageDetails.y2)
|
||||
self.tmpProfileImageDetails = ProfileImageDetails()
|
||||
|
||||
@ -374,7 +374,7 @@ proc setupAccount(self: Controller, accountId: string, storeToKeychain: bool) =
|
||||
self.delegate.emitStartupError(error, StartupErrorType.SetupAccError)
|
||||
else:
|
||||
self.setupKeychain(storeToKeychain)
|
||||
|
||||
|
||||
proc storeGeneratedAccountAndLogin*(self: Controller, storeToKeychain: bool) =
|
||||
let accounts = self.getGeneratedAccounts()
|
||||
if accounts.len == 0:
|
||||
@ -492,8 +492,8 @@ proc getLastReceivedKeycardData*(self: Controller): tuple[flowType: string, flow
|
||||
|
||||
proc cancelCurrentFlow*(self: Controller) =
|
||||
self.keycardService.cancelCurrentFlow()
|
||||
# in most cases we're running another flow after canceling the current one,
|
||||
# this way we're giving to the keycard some time to cancel the current flow
|
||||
# in most cases we're running another flow after canceling the current one,
|
||||
# this way we're giving to the keycard some time to cancel the current flow
|
||||
sleep(200)
|
||||
|
||||
proc runLoadAccountFlow*(self: Controller, seedPhraseLength = 0, seedPhrase = "", pin = "", puk = "", factoryReset = false) =
|
||||
@ -563,7 +563,7 @@ proc storeMetadataForNewKeycardUser(self: Controller) =
|
||||
|
||||
proc getConnectionString*(self: Controller): string =
|
||||
return self.tmpConnectionString
|
||||
|
||||
|
||||
proc setConnectionString*(self: Controller, connectionString: string) =
|
||||
self.tmpConnectionString = connectionString
|
||||
|
||||
|
@ -29,24 +29,27 @@ method getNextQuinaryState*(self: LoginKeycardEnterPinState, controller: Control
|
||||
controller.cancelCurrentFlow()
|
||||
return createState(StateType.LostKeycardOptions, self.flowType, self)
|
||||
|
||||
method resolveKeycardNextState*(self: LoginKeycardEnterPinState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||
method resolveKeycardNextState*(self: LoginKeycardEnterPinState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||
controller: Controller): State =
|
||||
let state = ensureReaderAndCardPresenceLogin(self, keycardFlowType, keycardEvent, controller)
|
||||
if not state.isNil:
|
||||
return state
|
||||
if self.flowType == FlowType.AppLogin:
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.error.len == 0:
|
||||
if not controller.keyUidMatchSelectedLoginAccount(keycardEvent.keyUid):
|
||||
controller.setPin("")
|
||||
return createState(StateType.LoginKeycardWrongKeycard, self.flowType, nil)
|
||||
controller.setKeycardEvent(keycardEvent)
|
||||
return createState(StateType.LoginKeycardPinVerified, self.flowType, nil)
|
||||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPIN:
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.LoginKeycardWrongPin, self.flowType, nil)
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, self.flowType, nil)
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len == 0:
|
||||
if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, self.flowType, nil)
|
@ -10,9 +10,12 @@ proc delete*(self: LoginKeycardWrongKeycardState) =
|
||||
|
||||
method executePrimaryCommand*(self: LoginKeycardWrongKeycardState, controller: Controller) =
|
||||
if self.flowType == FlowType.AppLogin:
|
||||
if controller.isSelectedLoginAccountKeycardAccount() and
|
||||
controller.getPin().len == PINLengthForStatusApp:
|
||||
if controller.isSelectedLoginAccountKeycardAccount():
|
||||
if controller.getPin().len == PINLengthForStatusApp:
|
||||
controller.enterKeycardPin(controller.getPin())
|
||||
else:
|
||||
controller.cancelCurrentFlow()
|
||||
controller.runLoginFlow()
|
||||
|
||||
method getNextTertiaryState*(self: LoginKeycardWrongKeycardState, controller: Controller): State =
|
||||
if self.flowType == FlowType.AppLogin:
|
||||
@ -29,6 +32,6 @@ method getNextQuinaryState*(self: LoginKeycardWrongKeycardState, controller: Con
|
||||
controller.cancelCurrentFlow()
|
||||
return createState(StateType.LostKeycardOptions, self.flowType, self)
|
||||
|
||||
method resolveKeycardNextState*(self: LoginKeycardWrongKeycardState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||
method resolveKeycardNextState*(self: LoginKeycardWrongKeycardState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||
controller: Controller): State =
|
||||
return ensureReaderAndCardPresenceAndResolveNextLoginState(self, keycardFlowType, keycardEvent, controller)
|
@ -1,5 +1,5 @@
|
||||
proc ensureReaderAndCardPresenceLogin*(state: State, keycardFlowType: string, keycardEvent: KeycardEvent, controller: Controller): State =
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.error.len > 0:
|
||||
if keycardEvent.error == ErrorPCSC:
|
||||
return createState(StateType.LoginNoPCSCService, state.flowType, nil)
|
||||
@ -8,7 +8,7 @@ proc ensureReaderAndCardPresenceLogin*(state: State, keycardFlowType: string, ke
|
||||
if state.stateType == StateType.LoginPlugin:
|
||||
return nil
|
||||
return createState(StateType.LoginPlugin, state.flowType, nil)
|
||||
if keycardFlowType == ResponseTypeValueInsertCard and
|
||||
if keycardFlowType == ResponseTypeValueInsertCard and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorConnection:
|
||||
controller.reRunCurrentFlowLater()
|
||||
@ -25,13 +25,14 @@ proc ensureReaderAndCardPresenceAndResolveNextLoginState*(state: State, keycardF
|
||||
if not ensureState.isNil:
|
||||
return ensureState
|
||||
if state.flowType == FlowType.AppLogin:
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||
keycardEvent.error.len == 0:
|
||||
controller.setKeycardEvent(keycardEvent)
|
||||
return createState(StateType.LoginKeycardPinVerified, state.flowType, nil)
|
||||
if keycardFlowType == ResponseTypeValueEnterPIN:
|
||||
if keycardEvent.error.len == 0:
|
||||
if not controller.keyUidMatchSelectedLoginAccount(keycardEvent.keyUid):
|
||||
controller.setPin("")
|
||||
return createState(StateType.LoginKeycardWrongKeycard, state.flowType, nil)
|
||||
return createState(StateType.LoginKeycardRecognizedKeycard, state.flowType, nil)
|
||||
if keycardEvent.error.len > 0:
|
||||
@ -40,11 +41,11 @@ proc ensureReaderAndCardPresenceAndResolveNextLoginState*(state: State, keycardF
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.LoginKeycardWrongPin, state.flowType, nil)
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, state.flowType, nil)
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len == 0:
|
||||
if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, state.flowType, nil)
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
if keycardFlowType == ResponseTypeValueSwapCard and
|
||||
keycardEvent.error.len > 0:
|
||||
if keycardEvent.error == ErrorNoKeys:
|
||||
return createState(StateType.LoginKeycardEmpty, state.flowType, nil)
|
||||
|
@ -113,19 +113,19 @@ method load*[T](self: Module[T]) =
|
||||
var thumbnailImage: string
|
||||
var largeImage: string
|
||||
self.extractImages(acc, thumbnailImage, largeImage)
|
||||
items.add(login_acc_item.initItem(order = i, acc.name, icon = "", thumbnailImage, largeImage, acc.keyUid, acc.colorHash,
|
||||
items.add(login_acc_item.initItem(order = i, acc.name, icon = "", thumbnailImage, largeImage, acc.keyUid, acc.colorHash,
|
||||
acc.colorId, acc.keycardPairing))
|
||||
# set the first account as slected one
|
||||
if items.len == 0:
|
||||
# we should never be here, since else block of `if (shouldStartWithOnboardingScreen)`
|
||||
# we should never be here, since else block of `if (shouldStartWithOnboardingScreen)`
|
||||
# ensures that `openedAccounts` is not empty array
|
||||
error "cannot run the app in login flow cause list of login accounts is empty"
|
||||
quit() # quit the app
|
||||
items.add(login_acc_item.initItem(order = items.len, name = atc.LOGIN_ACCOUNTS_LIST_ADD_NEW_USER, icon = "add",
|
||||
items.add(login_acc_item.initItem(order = items.len, name = atc.LOGIN_ACCOUNTS_LIST_ADD_NEW_USER, icon = "add",
|
||||
thumbnailImage = "", largeImage = "", keyUid = ""))
|
||||
items.add(login_acc_item.initItem(order = items.len, name = atc.LOGIN_ACCOUNTS_LIST_ADD_EXISTING_USER, icon = "wallet",
|
||||
items.add(login_acc_item.initItem(order = items.len, name = atc.LOGIN_ACCOUNTS_LIST_ADD_EXISTING_USER, icon = "wallet",
|
||||
thumbnailImage = "", largeImage = "", keyUid = ""))
|
||||
items.add(login_acc_item.initItem(order = items.len, name = atc.LOGIN_ACCOUNTS_LIST_LOST_KEYCARD, icon = "keycard",
|
||||
items.add(login_acc_item.initItem(order = items.len, name = atc.LOGIN_ACCOUNTS_LIST_LOST_KEYCARD, icon = "keycard",
|
||||
thumbnailImage = "", largeImage = "", keyUid = ""))
|
||||
self.view.setLoginAccountsModelItems(items)
|
||||
self.setSelectedLoginAccount(items[0])
|
||||
@ -139,8 +139,8 @@ method getKeycardSharedModule*[T](self: Module[T]): QVariant =
|
||||
return self.keycardSharedModule.getModuleAsVariant()
|
||||
|
||||
proc createSharedKeycardModule[T](self: Module[T]) =
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module[T]](self, UNIQUE_STARTUP_MODULE_IDENTIFIER,
|
||||
self.events, self.keycardService, settingsService = nil, networkService = nil, privacyService = nil, self.accountsService,
|
||||
self.keycardSharedModule = keycard_shared_module.newModule[Module[T]](self, UNIQUE_STARTUP_MODULE_IDENTIFIER,
|
||||
self.events, self.keycardService, settingsService = nil, networkService = nil, privacyService = nil, self.accountsService,
|
||||
walletAccountService = nil, self.keychainService)
|
||||
|
||||
method moveToLoadingAppState*[T](self: Module[T]) =
|
||||
@ -171,7 +171,7 @@ method onBackActionClicked*[T](self: Module[T]) =
|
||||
return
|
||||
self.view.setCurrentStartupState(backState)
|
||||
debug "back_action - set state", setCurrFlow=backState.flowType(), newCurrState=backState.stateType()
|
||||
|
||||
|
||||
method onPrimaryActionClicked*[T](self: Module[T]) =
|
||||
let currStateObj = self.view.currentStartupStateObj()
|
||||
if currStateObj.isNil:
|
||||
@ -284,6 +284,9 @@ method importAccountSuccess*[T](self: Module[T]) =
|
||||
|
||||
method setSelectedLoginAccount*[T](self: Module[T], item: login_acc_item.Item) =
|
||||
self.controller.cancelCurrentFlow()
|
||||
if item.getKeyUid().len == 0:
|
||||
error "all accounts must have non empty key uid"
|
||||
return
|
||||
self.controller.setSelectedLoginAccount(item.getKeyUid(), item.getKeycardCreatedAccount())
|
||||
if item.getKeycardCreatedAccount():
|
||||
self.view.setCurrentStartupState(newLoginState(state.FlowType.AppLogin, nil))
|
||||
@ -413,6 +416,8 @@ method onNodeLogin*[T](self: Module[T], error: string) =
|
||||
else:
|
||||
self.moveToStartupState()
|
||||
if currStateObj.flowType() == state.FlowType.AppLogin:
|
||||
self.view.setCurrentStartupState(newLoginState(state.FlowType.AppLogin, nil))
|
||||
self.controller.runLoginFlow()
|
||||
self.emitAccountLoginError(error)
|
||||
else:
|
||||
self.emitStartupError(error, StartupErrorType.SetupAccError)
|
||||
@ -443,7 +448,7 @@ method checkRepeatedKeycardPinWhileTyping*[T](self: Module[T], pin: string): boo
|
||||
if pin[i] != storedPin[i]:
|
||||
return false
|
||||
return true
|
||||
else:
|
||||
else:
|
||||
let match = pin == storedPin
|
||||
self.controller.setPinMatch(match)
|
||||
return match
|
||||
@ -459,13 +464,13 @@ method setKeycardData*[T](self: Module[T], value: string) =
|
||||
|
||||
method setRemainingAttempts*[T](self: Module[T], value: int) =
|
||||
self.view.setRemainingAttempts(value)
|
||||
|
||||
|
||||
method runFactoryResetPopup*[T](self: Module[T]) =
|
||||
self.createSharedKeycardModule()
|
||||
if self.keycardSharedModule.isNil:
|
||||
return
|
||||
self.keycardSharedModule.runFlow(keycard_shared_module.FlowType.FactoryReset)
|
||||
|
||||
|
||||
method onDisplayKeycardSharedModuleFlow*[T](self: Module[T]) =
|
||||
self.view.emitDisplayKeycardSharedModuleFlow()
|
||||
|
||||
@ -480,7 +485,7 @@ method onSharedKeycarModuleFlowTerminated*[T](self: Module[T], lastStepInTheCurr
|
||||
if currStateObj.isNil:
|
||||
error "cannot resolve current state for onboarding/login flow continuation"
|
||||
return
|
||||
if currStateObj.flowType() == state.FlowType.FirstRunNewUserNewKeycardKeys or
|
||||
if currStateObj.flowType() == state.FlowType.FirstRunNewUserNewKeycardKeys or
|
||||
currStateObj.flowType() == state.FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard or
|
||||
currStateObj.flowType() == state.FlowType.LostKeycardReplacement:
|
||||
let newState = currStateObj.getBackState()
|
||||
|
@ -1064,15 +1064,15 @@ Item {
|
||||
}
|
||||
PropertyChanges {
|
||||
target: message
|
||||
text: qsTr("Insert proper Keycard")
|
||||
text: qsTr("Insert the correct Keycard for this profile and try again.")
|
||||
visible: true
|
||||
font.pixelSize: Constants.keycard.general.fontSize2
|
||||
color: Theme.palette.baseColor1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: button
|
||||
text: ""
|
||||
visible: false
|
||||
text: qsTr("Try again")
|
||||
visible: true
|
||||
}
|
||||
PropertyChanges {
|
||||
target: link
|
||||
|
Loading…
x
Reference in New Issue
Block a user