From 6885fda217cf1f54fd3056e24d8d3b5d98d87d30 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Mon, 3 Apr 2023 15:29:14 +0200 Subject: [PATCH] fix(@desktop/general): authenticate with previously stored pass/pin to a Keychain issue fixed --- .../biometrics_ready_to_sign_state.nim | 25 ++++++++++++++++++- .../shared_modules/keycard_popup/module.nim | 7 +++--- .../popups/keycard/states/EnterPassword.qml | 4 +-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/app/modules/shared_modules/keycard_popup/internal/biometrics_ready_to_sign_state.nim b/src/app/modules/shared_modules/keycard_popup/internal/biometrics_ready_to_sign_state.nim index edbf432f56..3b06fe476c 100644 --- a/src/app/modules/shared_modules/keycard_popup/internal/biometrics_ready_to_sign_state.nim +++ b/src/app/modules/shared_modules/keycard_popup/internal/biometrics_ready_to_sign_state.nim @@ -26,4 +26,27 @@ method executeCancelCommand*(self: BiometricsReadyToSignState, controller: Contr method resolveKeycardNextState*(self: BiometricsReadyToSignState, keycardFlowType: string, keycardEvent: KeycardEvent, controller: Controller): State = - return ensureReaderAndCardPresenceAndResolveNextState(self, keycardFlowType, keycardEvent, controller) \ No newline at end of file + let state = ensureReaderAndCardPresence(self, keycardFlowType, keycardEvent, controller) + if not state.isNil: + return state + if self.flowType == FlowType.Authentication: + if keycardFlowType == ResponseTypeValueEnterPIN and + keycardEvent.error.len > 0 and + keycardEvent.error == ErrorPIN: + controller.setRemainingAttempts(keycardEvent.pinRetries) + if keycardEvent.pinRetries > 0: + if singletonInstance.userProfile.getUsingBiometricLogin() and not controller.usePinFromBiometrics(): + return createState(StateType.WrongKeychainPin, self.flowType, nil) + return createState(StateType.WrongPin, self.flowType, nil) + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueEnterPIN and + keycardEvent.error.len == 0: + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueEnterPUK and + keycardEvent.error.len == 0: + if keycardEvent.pinRetries == 0 and keycardEvent.pukRetries > 0: + return createState(StateType.MaxPinRetriesReached, self.flowType, nil) + if keycardFlowType == ResponseTypeValueKeycardFlowResult: + if keycardEvent.error.len == 0: + controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) + return nil \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/module.nim b/src/app/modules/shared_modules/keycard_popup/module.nim index 2eb6c9010c..bc8142f8af 100644 --- a/src/app/modules/shared_modules/keycard_popup/module.nim +++ b/src/app/modules/shared_modules/keycard_popup/module.nim @@ -454,14 +454,14 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path if flowToRun == FlowType.Authentication: self.controller.connectKeychainSignals() if keyUid.len == 0 or keyUid == singletonInstance.userProfile.getKeyUid(): - if singletonInstance.userProfile.getUsingBiometricLogin(): - self.controller.tryToObtainDataFromKeychain() - return if singletonInstance.userProfile.getIsKeycardUser(): self.prepareKeyPairItemForAuthentication(singletonInstance.userProfile.getKeyUid()) self.tmpLocalState = newReadingKeycardState(flowToRun, nil) self.controller.runAuthenticationFlow(singletonInstance.userProfile.getKeyUid()) return + if singletonInstance.userProfile.getUsingBiometricLogin(): + self.controller.tryToObtainDataFromKeychain() + return self.view.setCurrentState(newEnterPasswordState(flowToRun, nil)) self.authenticationPopupIsAlreadyRunning = true self.controller.readyToDisplayPopup() @@ -629,6 +629,7 @@ method keychainObtainedDataSuccess*[T](self: Module[T], data: string) = return if not currStateObj.isNil: if data.len == PINLengthForStatusApp: + self.controller.setPin(data) self.controller.enterKeycardPin(data) else: self.view.setCurrentState(newBiometricsPinInvalidState(FlowType.Authentication, nil)) \ No newline at end of file diff --git a/ui/imports/shared/popups/keycard/states/EnterPassword.qml b/ui/imports/shared/popups/keycard/states/EnterPassword.qml index b6376404c4..bc16ba7d4c 100644 --- a/ui/imports/shared/popups/keycard/states/EnterPassword.qml +++ b/ui/imports/shared/popups/keycard/states/EnterPassword.qml @@ -169,7 +169,7 @@ Item { } PropertyChanges { target: title - text: qsTr("Password changed on other device") + text: qsTr("Stored password doesn't match") font.pixelSize: Constants.keycard.general.fontSize1 color: Theme.palette.directColor1 } @@ -194,7 +194,7 @@ Item { } PropertyChanges { target: title - text: qsTr("Password changed on other device") + text: qsTr("Stored password doesn't match") font.pixelSize: Constants.keycard.general.fontSize1 color: Theme.palette.directColor1 }