diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 0528f1b47a..531267243b 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -390,7 +390,7 @@ proc buildAndRegisterUserProfile(self: AppController) = info "login account name and display name stored in settings differ" displayName = loggedInAccount.name - singletonInstance.userProfile.setFixedData(alias, loggedInAccount.keyUid, pubKey) + singletonInstance.userProfile.setFixedData(alias, loggedInAccount.keyUid, pubKey, loggedInAccount.keycardPairing.len > 0) singletonInstance.userProfile.setDisplayName(displayName) singletonInstance.userProfile.setPreferredName(preferredName) singletonInstance.userProfile.setEnsName(firstEnsName) diff --git a/src/app/global/user_profile.nim b/src/app/global/user_profile.nim index 9ce16996cd..24279559e4 100644 --- a/src/app/global/user_profile.nim +++ b/src/app/global/user_profile.nim @@ -8,6 +8,7 @@ QtObject: username: string keyUid: string pubKey: string + isKeycardUser: bool # fields which may change during runtime ensName: string displayName: string @@ -27,24 +28,28 @@ QtObject: new(result, delete) result.setup - proc setFixedData*(self: UserProfile, username: string, keyUid: string, pubKey: string) = + proc setFixedData*(self: UserProfile, username: string, keyUid: string, pubKey: string, isKeycardUser: bool) = self.username = username self.keyUid = keyUid self.pubKey = pubKey + self.isKeycardUser = isKeycardUser proc getKeyUid*(self: UserProfile): string {.slot.} = self.keyUid - QtProperty[string] keyUid: read = getKeyUid proc getPubKey*(self: UserProfile): string {.slot.} = self.pubKey - QtProperty[string] pubKey: read = getPubKey + proc getIsKeycardUser*(self: UserProfile): bool {.slot.} = + self.isKeycardUser + QtProperty[bool] isKeycardUser: + read = getIsKeycardUser + proc nameChanged*(self: UserProfile) {.signal.} proc getUsername*(self: UserProfile): string {.slot.} = diff --git a/src/app/modules/main/wallet_section/accounts/controller.nim b/src/app/modules/main/wallet_section/accounts/controller.nim index e872c2a4c9..5bb82d567d 100644 --- a/src/app/modules/main/wallet_section/accounts/controller.nim +++ b/src/app/modules/main/wallet_section/accounts/controller.nim @@ -77,9 +77,6 @@ proc loggedInUserUsesBiometricLogin*(self: Controller): bool = return false return true -proc getLoggedInAccount*(self: Controller): AccountDto = - return self.accountsService.getLoggedInAccount() - proc authenticateUser*(self: Controller, keyUid = "") = let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_IDENTIFIER, keyUid: keyUid) diff --git a/src/app/modules/main/wallet_section/accounts/io_interface.nim b/src/app/modules/main/wallet_section/accounts/io_interface.nim index 58968844b5..4191a5ccf3 100644 --- a/src/app/modules/main/wallet_section/accounts/io_interface.nim +++ b/src/app/modules/main/wallet_section/accounts/io_interface.nim @@ -56,7 +56,4 @@ method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} = raise newException(ValueError, "No implementation available") method loggedInUserUsesBiometricLogin*(self: AccessInterface): bool {.base.} = - raise newException(ValueError, "No implementation available") - -method isProfileKeyPairMigrated*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/wallet_section/accounts/module.nim b/src/app/modules/main/wallet_section/accounts/module.nim index 94ef31a316..ec96b9dce3 100644 --- a/src/app/modules/main/wallet_section/accounts/module.nim +++ b/src/app/modules/main/wallet_section/accounts/module.nim @@ -176,11 +176,8 @@ method validSeedPhrase*(self: Module, value: string): bool = method loggedInUserUsesBiometricLogin*(self: Module): bool = return self.controller.loggedInUserUsesBiometricLogin() -method isProfileKeyPairMigrated*(self: Module): bool = - return self.controller.getLoggedInAccount().keycardPairing.len > 0 - method authenticateUser*(self: Module) = - if self.isProfileKeyPairMigrated(): + if singletonInstance.userProfile.getIsKeycardUser(): let keyUid = singletonInstance.userProfile.getKeyUid() self.controller.authenticateUser(keyUid) else: diff --git a/src/app/modules/main/wallet_section/accounts/view.nim b/src/app/modules/main/wallet_section/accounts/view.nim index b917509fef..fc28a68303 100644 --- a/src/app/modules/main/wallet_section/accounts/view.nim +++ b/src/app/modules/main/wallet_section/accounts/view.nim @@ -285,7 +285,4 @@ QtObject: self.delegate.authenticateUser() proc loggedInUserUsesBiometricLogin*(self: View): bool {.slot.} = - return self.delegate.loggedInUserUsesBiometricLogin() - - proc isProfileKeyPairMigrated*(self: View): bool {.slot.} = - return self.delegate.isProfileKeyPairMigrated() \ No newline at end of file + return self.delegate.loggedInUserUsesBiometricLogin() \ No newline at end of file diff --git a/src/app/modules/shared_modules/keycard_popup/io_interface.nim b/src/app/modules/shared_modules/keycard_popup/io_interface.nim index dc1bffa1b9..ee63689e65 100644 --- a/src/app/modules/shared_modules/keycard_popup/io_interface.nim +++ b/src/app/modules/shared_modules/keycard_popup/io_interface.nim @@ -127,9 +127,6 @@ method loggedInUserUsesBiometricLogin*(self: AccessInterface): bool {.base.} = method migratingProfileKeyPair*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") -method isProfileKeyPairMigrated*(self: AccessInterface): bool {.base.} = - raise newException(ValueError, "No implementation available") - method getSigningPhrase*(self: AccessInterface): string {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/shared_modules/keycard_popup/module.nim b/src/app/modules/shared_modules/keycard_popup/module.nim index 2d9dbae84e..92e517be84 100644 --- a/src/app/modules/shared_modules/keycard_popup/module.nim +++ b/src/app/modules/shared_modules/keycard_popup/module.nim @@ -108,9 +108,6 @@ method loggedInUserUsesBiometricLogin*[T](self: Module[T]): bool = method migratingProfileKeyPair*[T](self: Module[T]): bool = return self.controller.getSelectedKeyPairIsProfile() -method isProfileKeyPairMigrated*[T](self: Module[T]): bool = - return self.controller.getLoggedInAccount().keycardPairing.len > 0 - method getSigningPhrase*[T](self: Module[T]): string = return self.controller.getSigningPhrase() diff --git a/src/app/modules/shared_modules/keycard_popup/view.nim b/src/app/modules/shared_modules/keycard_popup/view.nim index aa8351c821..61799ab533 100644 --- a/src/app/modules/shared_modules/keycard_popup/view.nim +++ b/src/app/modules/shared_modules/keycard_popup/view.nim @@ -194,8 +194,5 @@ QtObject: proc migratingProfileKeyPair*(self: View): bool {.slot.} = return self.delegate.migratingProfileKeyPair() - proc isProfileKeyPairMigrated*(self: View): bool {.slot.} = - return self.delegate.isProfileKeyPairMigrated() - proc getSigningPhrase*(self: View): string {.slot.} = return self.delegate.getSigningPhrase() \ No newline at end of file diff --git a/ui/app/AppLayouts/Wallet/popups/AddAccountModal.qml b/ui/app/AppLayouts/Wallet/popups/AddAccountModal.qml index 6716ad17de..23b58b5280 100644 --- a/ui/app/AppLayouts/Wallet/popups/AddAccountModal.qml +++ b/ui/app/AppLayouts/Wallet/popups/AddAccountModal.qml @@ -281,7 +281,7 @@ StatusModal { if (d.authenticationNeeded) { if (RootStore.loggedInUserUsesBiometricLogin()) return "touch-id" - if (RootStore.isProfileKeyPairMigrated()) + if (RootStore.loggedInUserIsKeycardUser()) return "keycard" return "password" } diff --git a/ui/app/AppLayouts/Wallet/stores/RootStore.qml b/ui/app/AppLayouts/Wallet/stores/RootStore.qml index 57ef21bba1..a05e240b01 100644 --- a/ui/app/AppLayouts/Wallet/stores/RootStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/RootStore.qml @@ -231,7 +231,7 @@ QtObject { return walletSectionAccounts.loggedInUserUsesBiometricLogin() } - function isProfileKeyPairMigrated() { - return walletSectionAccounts.isProfileKeyPairMigrated() + function loggedInUserIsKeycardUser() { + return userProfile.isKeycardUser } } diff --git a/ui/imports/shared/popups/keycard/KeycardPopup.qml b/ui/imports/shared/popups/keycard/KeycardPopup.qml index 5168bd0662..b13f0dff67 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopup.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopup.qml @@ -708,9 +708,10 @@ StatusModal { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterSeedPhrase) { if (root.sharedKeycardModule.loggedInUserUsesBiometricLogin()) return "touch-id" - if (root.sharedKeycardModule.isProfileKeyPairMigrated()) + if (userProfile.isKeycardUser()) return "keycard" return "password" + if (userProfile.isKeycardUser) } } if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication) { diff --git a/ui/imports/shared/popups/keycard/states/SelectKeyPair.qml b/ui/imports/shared/popups/keycard/states/SelectKeyPair.qml index 9ad3ef0f2b..0dce3eb02d 100644 --- a/ui/imports/shared/popups/keycard/states/SelectKeyPair.qml +++ b/ui/imports/shared/popups/keycard/states/SelectKeyPair.qml @@ -59,7 +59,7 @@ Item { } StatusBaseText { - visible: !root.sharedKeycardModule.isProfileKeyPairMigrated() + visible: !userProfile.isKeycardUser Layout.preferredWidth: parent.width - 2 * Style.current.padding Layout.leftMargin: Style.current.padding Layout.alignment: Qt.AlignLeft @@ -70,7 +70,7 @@ Item { } KeyPairList { - visible: !root.sharedKeycardModule.isProfileKeyPairMigrated() + visible: !userProfile.isKeycardUser Layout.fillWidth: true Layout.preferredHeight: 100 Layout.fillHeight: visible && root.sharedKeycardModule.keyPairModel.count === 1 @@ -88,8 +88,8 @@ Item { } StatusBaseText { - visible: root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 0 || - !root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 1 + visible: userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 0 || + !userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 1 Layout.preferredWidth: parent.width - 2 * Style.current.padding Layout.leftMargin: Style.current.padding Layout.alignment: Qt.AlignLeft @@ -100,8 +100,8 @@ Item { } KeyPairList { - visible: root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 0 || - !root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 1 + visible: userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 0 || + !userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 1 Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignLeft