refactor(@desktop/keycard): `remainingAttempts` introduced as new prop, instead of using `keycardData` prop
This commit is contained in:
parent
192b5426b2
commit
c64d5560a6
|
@ -161,6 +161,9 @@ proc getKeycardData*(self: Controller): string =
|
|||
proc setKeycardData*(self: Controller, value: string) =
|
||||
self.delegate.setKeycardData(value)
|
||||
|
||||
proc setRemainingAttempts*(self: Controller, value: int) =
|
||||
self.delegate.setRemainingAttempts(value)
|
||||
|
||||
proc containsMetadata*(self: Controller): bool =
|
||||
return self.tmpKeycardContainsMetadata
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
return createState(StateType.MaxPinRetriesReached, self.flowType, nil)
|
||||
|
@ -68,7 +68,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseUnlockLabelForLockedState, add = true))
|
||||
|
@ -89,7 +89,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
if singletonInstance.userProfile.getUsingBiometricLogin() and not controller.usePinFromBiometrics():
|
||||
return createState(StateType.WrongKeychainPin, self.flowType, nil)
|
||||
|
@ -112,7 +112,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
return createState(StateType.MaxPinRetriesReached, self.flowType, nil)
|
||||
|
@ -130,7 +130,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
@ -151,7 +151,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
@ -172,7 +172,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
@ -193,7 +193,7 @@ method resolveKeycardNextState*(self: EnterPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.WrongPin, self.flowType, nil)
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
|
|
@ -30,7 +30,7 @@ method resolveKeycardNextState*(self: EnterPukState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.WrongPuk, self.flowType, self.getBackState)
|
||||
return createState(StateType.MaxPukRetriesReached, self.flowType, nil)
|
|
@ -48,7 +48,7 @@ method resolveKeycardNextState*(self: RepeatPinState, keycardFlowType: string, k
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.PinSet, self.flowType, nil)
|
||||
|
|
|
@ -139,7 +139,7 @@ proc ensureReaderAndCardPresenceAndResolveNextState*(state: State, keycardFlowTy
|
|||
if singletonInstance.userProfile.getUsingBiometricLogin():
|
||||
if keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
if not controller.usePinFromBiometrics():
|
||||
return createState(StateType.WrongKeychainPin, state.flowType, nil)
|
||||
|
|
|
@ -27,7 +27,7 @@ method resolveKeycardNextState*(self: WrongKeychainPinState, keycardFlowType: st
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
return createState(StateType.MaxPinRetriesReached, self.flowType, nil)
|
||||
|
|
|
@ -56,7 +56,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
return createState(StateType.MaxPinRetriesReached, self.flowType, nil)
|
||||
|
@ -71,7 +71,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.UseUnlockLabelForLockedState, add = true))
|
||||
|
@ -88,7 +88,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
return createState(StateType.MaxPinRetriesReached, self.flowType, nil)
|
||||
|
@ -104,7 +104,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
return createState(StateType.MaxPinRetriesReached, self.flowType, nil)
|
||||
|
@ -119,7 +119,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
@ -136,7 +136,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
@ -153,7 +153,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
@ -170,7 +170,7 @@ method resolveKeycardNextState*(self: WrongPinState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == ErrorPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
controller.setKeycardData(updatePredefinedKeycardData(controller.getKeycardData(), PredefinedKeycardData.HideKeyPair, add = true))
|
||||
|
|
|
@ -26,7 +26,7 @@ method resolveKeycardNextState*(self: WrongPukState, keycardFlowType: string, ke
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return nil
|
||||
|
|
|
@ -81,6 +81,9 @@ method getKeycardData*(self: AccessInterface): string {.base.} =
|
|||
method setKeycardData*(self: AccessInterface, value: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setRemainingAttempts*(self: AccessInterface, value: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onBackActionClicked*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ method getKeycardData*[T](self: Module[T]): string =
|
|||
method setKeycardData*[T](self: Module[T], value: string) =
|
||||
self.view.setKeycardData(value)
|
||||
|
||||
method setRemainingAttempts*[T](self: Module[T], value: int) =
|
||||
self.view.setRemainingAttempts(value)
|
||||
|
||||
method setUidOfAKeycardWhichNeedToBeProcessed*[T](self: Module[T], value: string) =
|
||||
self.controller.setUidOfAKeycardWhichNeedToBeProcessed(value)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ QtObject:
|
|||
keyPairForProcessing: KeyPairSelectedItem
|
||||
keyPairForProcessingVariant: QVariant
|
||||
keycardData: string # used to temporary store the data coming from keycard, depends on current state different data may be stored
|
||||
remainingAttempts: int
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.currentStateVariant.delete
|
||||
|
@ -53,6 +54,7 @@ QtObject:
|
|||
result.delegate = delegate
|
||||
result.currentState = newStateWrapper()
|
||||
result.currentStateVariant = newQVariant(result.currentState)
|
||||
result.remainingAttempts = -1
|
||||
|
||||
signalConnect(result.currentState, "backActionClicked()", result, "onBackActionClicked()", 2)
|
||||
signalConnect(result.currentState, "cancelActionClicked()", result, "onCancelActionClicked()", 2)
|
||||
|
@ -82,6 +84,18 @@ QtObject:
|
|||
write = setKeycardData
|
||||
notify = keycardDataChanged
|
||||
|
||||
proc remainingAttemptsChanged*(self: View) {.signal.}
|
||||
proc setRemainingAttempts*(self: View, value: int) =
|
||||
if self.remainingAttempts == value:
|
||||
return
|
||||
self.remainingAttempts = value
|
||||
self.remainingAttemptsChanged()
|
||||
proc getRemainingAttempts*(self: View): int {.slot.} =
|
||||
return self.remainingAttempts
|
||||
QtProperty[int] remainingAttempts:
|
||||
read = getRemainingAttempts
|
||||
notify = remainingAttemptsChanged
|
||||
|
||||
proc onBackActionClicked*(self: View) {.slot.} =
|
||||
self.delegate.onBackActionClicked()
|
||||
|
||||
|
|
|
@ -230,6 +230,9 @@ proc getKeycardData*(self: Controller): string =
|
|||
proc setKeycardData*(self: Controller, value: string) =
|
||||
self.delegate.setKeycardData(value)
|
||||
|
||||
proc setRemainingAttempts*(self: Controller, value: int) =
|
||||
self.delegate.setRemainingAttempts(value)
|
||||
|
||||
proc setKeycardEvent*(self: Controller, value: KeycardEvent) =
|
||||
self.tmpKeycardEvent = value
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ method resolveKeycardNextState*(self: KeycardEnterPinState, keycardFlowType: str
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.KeycardWrongPin, self.flowType, self.getBackState)
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, self.flowType, self.getBackState)
|
||||
|
|
|
@ -29,7 +29,7 @@ method resolveKeycardNextState*(self: KeycardEnterPukState, keycardFlowType: str
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardWrongPuk, self.flowType, self.getBackState)
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, self.flowType, self.getBackState)
|
||||
|
@ -41,7 +41,7 @@ method resolveKeycardNextState*(self: KeycardEnterPukState, keycardFlowType: str
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardWrongPuk, self.flowType, self.getBackState)
|
||||
return createState(StateType.KeycardMaxPukRetriesReached, self.flowType, self.getBackState)
|
|
@ -44,7 +44,7 @@ method resolveKeycardNextState*(self: KeycardRepeatPinState, keycardFlowType: st
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardPinSet, self.flowType, self.getBackState)
|
||||
|
@ -57,7 +57,7 @@ method resolveKeycardNextState*(self: KeycardRepeatPinState, keycardFlowType: st
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return createState(StateType.KeycardPinSet, self.flowType, self.getBackState)
|
||||
|
|
|
@ -27,7 +27,7 @@ method resolveKeycardNextState*(self: KeycardWrongPinState, keycardFlowType: str
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return self
|
||||
return createState(StateType.KeycardMaxPinRetriesReached, self.flowType, self.getBackState)
|
||||
|
|
|
@ -25,7 +25,7 @@ method resolveKeycardNextState*(self: KeycardWrongPukState, keycardFlowType: str
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return nil
|
||||
|
@ -46,7 +46,7 @@ method resolveKeycardNextState*(self: KeycardWrongPukState, keycardFlowType: str
|
|||
if keycardFlowType == ResponseTypeValueEnterPUK and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPUK:
|
||||
controller.setKeycardData($keycardEvent.pukRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pukRetries)
|
||||
controller.setPukValid(false)
|
||||
if keycardEvent.pukRetries > 0:
|
||||
return nil
|
||||
|
|
|
@ -37,7 +37,7 @@ method resolveKeycardNextState*(self: LoginKeycardEnterPinState, keycardFlowType
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.LoginKeycardWrongPin, self.flowType, nil)
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, self.flowType, nil)
|
||||
|
|
|
@ -35,7 +35,7 @@ method resolveKeycardNextState*(self: LoginKeycardWrongPinState, keycardFlowType
|
|||
if keycardFlowType == ResponseTypeValueEnterPIN and
|
||||
keycardEvent.error.len > 0 and
|
||||
keycardEvent.error == RequestParamPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return nil
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, self.flowType, nil)
|
||||
|
|
|
@ -326,7 +326,7 @@ proc ensureReaderAndCardPresenceAndResolveNextLoginState*(state: State, keycardF
|
|||
return createState(StateType.LoginKeycardRecognizedKeycard, state.flowType, nil)
|
||||
if keycardEvent.error.len > 0:
|
||||
if keycardEvent.error == RequestParamPIN:
|
||||
controller.setKeycardData($keycardEvent.pinRetries)
|
||||
controller.setRemainingAttempts(keycardEvent.pinRetries)
|
||||
if keycardEvent.pinRetries > 0:
|
||||
return createState(StateType.LoginKeycardWrongPin, state.flowType, nil)
|
||||
return createState(StateType.LoginKeycardMaxPinRetriesReached, state.flowType, nil)
|
||||
|
|
|
@ -133,6 +133,9 @@ method getKeycardData*(self: AccessInterface): string {.base.} =
|
|||
method setKeycardData*(self: AccessInterface, value: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setRemainingAttempts*(self: AccessInterface, value: int) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method runFactoryResetPopup*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -347,6 +347,9 @@ method getKeycardData*[T](self: Module[T]): string =
|
|||
method setKeycardData*[T](self: Module[T], value: string) =
|
||||
self.view.setKeycardData(value)
|
||||
|
||||
method setRemainingAttempts*[T](self: Module[T], value: int) =
|
||||
self.view.setRemainingAttempts(value)
|
||||
|
||||
method runFactoryResetPopup*[T](self: Module[T]) =
|
||||
self.createSharedKeycardModule()
|
||||
if self.keycardSharedModule.isNil:
|
||||
|
|
|
@ -28,6 +28,7 @@ QtObject:
|
|||
loginAccountsModelVariant: QVariant
|
||||
appState: AppState
|
||||
keycardData: string # used to temporary store the data coming from keycard, depends on current state different data may be stored
|
||||
remainingAttempts: int
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.currentStartupStateVariant.delete
|
||||
|
@ -54,6 +55,7 @@ QtObject:
|
|||
result.selectedLoginAccountVariant = newQVariant(result.selectedLoginAccount)
|
||||
result.loginAccountsModel = login_acc_model.newModel()
|
||||
result.loginAccountsModelVariant = newQVariant(result.loginAccountsModel)
|
||||
result.remainingAttempts = -1
|
||||
|
||||
signalConnect(result.currentStartupState, "backActionClicked()", result, "onBackActionClicked()", 2)
|
||||
signalConnect(result.currentStartupState, "primaryActionClicked()", result, "onPrimaryActionClicked()", 2)
|
||||
|
@ -250,6 +252,18 @@ QtObject:
|
|||
read = getKeycardData
|
||||
notify = keycardDataChanged
|
||||
|
||||
proc remainingAttemptsChanged*(self: View) {.signal.}
|
||||
proc setRemainingAttempts*(self: View, value: int) =
|
||||
if self.remainingAttempts == value:
|
||||
return
|
||||
self.remainingAttempts = value
|
||||
self.remainingAttemptsChanged()
|
||||
proc getRemainingAttempts*(self: View): int {.slot.} =
|
||||
return self.remainingAttempts
|
||||
QtProperty[int] remainingAttempts:
|
||||
read = getRemainingAttempts
|
||||
notify = remainingAttemptsChanged
|
||||
|
||||
proc displayKeycardSharedModuleFlow*(self: View) {.signal.}
|
||||
proc emitDisplayKeycardSharedModuleFlow*(self: View) =
|
||||
self.displayKeycardSharedModuleFlow()
|
||||
|
|
|
@ -18,7 +18,7 @@ Item {
|
|||
|
||||
property StartupStore startupStore
|
||||
|
||||
property int remainingAttempts: parseInt(root.startupStore.startupModuleInst.keycardData, 10)
|
||||
property int remainingAttempts: root.startupStore.startupModuleInst.remainingAttempts
|
||||
|
||||
onRemainingAttemptsChanged: {
|
||||
if (root.startupStore.currentStartupState.stateType === Constants.startupState.keycardWrongPin) {
|
||||
|
|
|
@ -16,7 +16,7 @@ Item {
|
|||
|
||||
property StartupStore startupStore
|
||||
|
||||
property int remainingAttempts: parseInt(root.startupStore.startupModuleInst.keycardData, 10)
|
||||
property int remainingAttempts: root.startupStore.startupModuleInst.remainingAttempts
|
||||
|
||||
Component.onCompleted: {
|
||||
d.allEntriesValid = false
|
||||
|
|
|
@ -64,7 +64,7 @@ Item {
|
|||
readonly property string stateLoginRegularUser: "regularUserLogin"
|
||||
readonly property string stateLoginKeycardUser: "keycardUserLogin"
|
||||
|
||||
property int remainingAttempts: parseInt(root.startupStore.startupModuleInst.keycardData, 10)
|
||||
property int remainingAttempts: root.startupStore.startupModuleInst.remainingAttempts
|
||||
onRemainingAttemptsChanged: {
|
||||
pinInputField.statesInitialization()
|
||||
pinInputField.forceFocus()
|
||||
|
|
|
@ -17,7 +17,7 @@ Item {
|
|||
|
||||
property var sharedKeycardModule
|
||||
|
||||
property int remainingAttempts: parseInt(root.sharedKeycardModule.keycardData, 10)
|
||||
property int remainingAttempts: root.sharedKeycardModule.remainingAttempts
|
||||
|
||||
signal pinUpdated(string pin)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Item {
|
|||
|
||||
property var sharedKeycardModule
|
||||
|
||||
property int remainingAttempts: parseInt(root.sharedKeycardModule.keycardData, 10)
|
||||
property int remainingAttempts: root.sharedKeycardModule.remainingAttempts
|
||||
|
||||
signal pukUpdated(string puk)
|
||||
|
||||
|
|
Loading…
Reference in New Issue