chore(@desktop/keycard): `isKeycardUser` prop added to the user profile global instance

This commit is contained in:
Sale Djenic 2022-09-26 13:01:26 +02:00 committed by saledjenic
parent 08ef68706f
commit 3687df2a2f
13 changed files with 22 additions and 37 deletions

View File

@ -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)

View File

@ -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.} =

View File

@ -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)

View File

@ -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")

View File

@ -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:

View File

@ -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()
return self.delegate.loggedInUserUsesBiometricLogin()

View File

@ -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")

View File

@ -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()

View File

@ -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()

View File

@ -281,7 +281,7 @@ StatusModal {
if (d.authenticationNeeded) {
if (RootStore.loggedInUserUsesBiometricLogin())
return "touch-id"
if (RootStore.isProfileKeyPairMigrated())
if (RootStore.loggedInUserIsKeycardUser())
return "keycard"
return "password"
}

View File

@ -231,7 +231,7 @@ QtObject {
return walletSectionAccounts.loggedInUserUsesBiometricLogin()
}
function isProfileKeyPairMigrated() {
return walletSectionAccounts.isProfileKeyPairMigrated()
function loggedInUserIsKeycardUser() {
return userProfile.isKeycardUser
}
}

View File

@ -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) {

View File

@ -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