chore(@desktop/keycard): `isKeycardUser` prop added to the user profile global instance
This commit is contained in:
parent
08ef68706f
commit
3687df2a2f
|
@ -390,7 +390,7 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
||||||
info "login account name and display name stored in settings differ"
|
info "login account name and display name stored in settings differ"
|
||||||
displayName = loggedInAccount.name
|
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.setDisplayName(displayName)
|
||||||
singletonInstance.userProfile.setPreferredName(preferredName)
|
singletonInstance.userProfile.setPreferredName(preferredName)
|
||||||
singletonInstance.userProfile.setEnsName(firstEnsName)
|
singletonInstance.userProfile.setEnsName(firstEnsName)
|
||||||
|
|
|
@ -8,6 +8,7 @@ QtObject:
|
||||||
username: string
|
username: string
|
||||||
keyUid: string
|
keyUid: string
|
||||||
pubKey: string
|
pubKey: string
|
||||||
|
isKeycardUser: bool
|
||||||
# fields which may change during runtime
|
# fields which may change during runtime
|
||||||
ensName: string
|
ensName: string
|
||||||
displayName: string
|
displayName: string
|
||||||
|
@ -27,24 +28,28 @@ QtObject:
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
result.setup
|
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.username = username
|
||||||
self.keyUid = keyUid
|
self.keyUid = keyUid
|
||||||
self.pubKey = pubKey
|
self.pubKey = pubKey
|
||||||
|
self.isKeycardUser = isKeycardUser
|
||||||
|
|
||||||
proc getKeyUid*(self: UserProfile): string {.slot.} =
|
proc getKeyUid*(self: UserProfile): string {.slot.} =
|
||||||
self.keyUid
|
self.keyUid
|
||||||
|
|
||||||
QtProperty[string] keyUid:
|
QtProperty[string] keyUid:
|
||||||
read = getKeyUid
|
read = getKeyUid
|
||||||
|
|
||||||
|
|
||||||
proc getPubKey*(self: UserProfile): string {.slot.} =
|
proc getPubKey*(self: UserProfile): string {.slot.} =
|
||||||
self.pubKey
|
self.pubKey
|
||||||
|
|
||||||
QtProperty[string] pubKey:
|
QtProperty[string] pubKey:
|
||||||
read = getPubKey
|
read = getPubKey
|
||||||
|
|
||||||
|
proc getIsKeycardUser*(self: UserProfile): bool {.slot.} =
|
||||||
|
self.isKeycardUser
|
||||||
|
QtProperty[bool] isKeycardUser:
|
||||||
|
read = getIsKeycardUser
|
||||||
|
|
||||||
proc nameChanged*(self: UserProfile) {.signal.}
|
proc nameChanged*(self: UserProfile) {.signal.}
|
||||||
|
|
||||||
proc getUsername*(self: UserProfile): string {.slot.} =
|
proc getUsername*(self: UserProfile): string {.slot.} =
|
||||||
|
|
|
@ -77,9 +77,6 @@ proc loggedInUserUsesBiometricLogin*(self: Controller): bool =
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc getLoggedInAccount*(self: Controller): AccountDto =
|
|
||||||
return self.accountsService.getLoggedInAccount()
|
|
||||||
|
|
||||||
proc authenticateUser*(self: Controller, keyUid = "") =
|
proc authenticateUser*(self: Controller, keyUid = "") =
|
||||||
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_IDENTIFIER,
|
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_IDENTIFIER,
|
||||||
keyUid: keyUid)
|
keyUid: keyUid)
|
||||||
|
|
|
@ -57,6 +57,3 @@ method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =
|
||||||
|
|
||||||
method loggedInUserUsesBiometricLogin*(self: AccessInterface): bool {.base.} =
|
method loggedInUserUsesBiometricLogin*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method isProfileKeyPairMigrated*(self: AccessInterface): bool {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
|
@ -176,11 +176,8 @@ method validSeedPhrase*(self: Module, value: string): bool =
|
||||||
method loggedInUserUsesBiometricLogin*(self: Module): bool =
|
method loggedInUserUsesBiometricLogin*(self: Module): bool =
|
||||||
return self.controller.loggedInUserUsesBiometricLogin()
|
return self.controller.loggedInUserUsesBiometricLogin()
|
||||||
|
|
||||||
method isProfileKeyPairMigrated*(self: Module): bool =
|
|
||||||
return self.controller.getLoggedInAccount().keycardPairing.len > 0
|
|
||||||
|
|
||||||
method authenticateUser*(self: Module) =
|
method authenticateUser*(self: Module) =
|
||||||
if self.isProfileKeyPairMigrated():
|
if singletonInstance.userProfile.getIsKeycardUser():
|
||||||
let keyUid = singletonInstance.userProfile.getKeyUid()
|
let keyUid = singletonInstance.userProfile.getKeyUid()
|
||||||
self.controller.authenticateUser(keyUid)
|
self.controller.authenticateUser(keyUid)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -286,6 +286,3 @@ QtObject:
|
||||||
|
|
||||||
proc loggedInUserUsesBiometricLogin*(self: View): bool {.slot.} =
|
proc loggedInUserUsesBiometricLogin*(self: View): bool {.slot.} =
|
||||||
return self.delegate.loggedInUserUsesBiometricLogin()
|
return self.delegate.loggedInUserUsesBiometricLogin()
|
||||||
|
|
||||||
proc isProfileKeyPairMigrated*(self: View): bool {.slot.} =
|
|
||||||
return self.delegate.isProfileKeyPairMigrated()
|
|
|
@ -127,9 +127,6 @@ method loggedInUserUsesBiometricLogin*(self: AccessInterface): bool {.base.} =
|
||||||
method migratingProfileKeyPair*(self: AccessInterface): bool {.base.} =
|
method migratingProfileKeyPair*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method isProfileKeyPairMigrated*(self: AccessInterface): bool {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
method getSigningPhrase*(self: AccessInterface): string {.base.} =
|
method getSigningPhrase*(self: AccessInterface): string {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -108,9 +108,6 @@ method loggedInUserUsesBiometricLogin*[T](self: Module[T]): bool =
|
||||||
method migratingProfileKeyPair*[T](self: Module[T]): bool =
|
method migratingProfileKeyPair*[T](self: Module[T]): bool =
|
||||||
return self.controller.getSelectedKeyPairIsProfile()
|
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 =
|
method getSigningPhrase*[T](self: Module[T]): string =
|
||||||
return self.controller.getSigningPhrase()
|
return self.controller.getSigningPhrase()
|
||||||
|
|
||||||
|
|
|
@ -194,8 +194,5 @@ QtObject:
|
||||||
proc migratingProfileKeyPair*(self: View): bool {.slot.} =
|
proc migratingProfileKeyPair*(self: View): bool {.slot.} =
|
||||||
return self.delegate.migratingProfileKeyPair()
|
return self.delegate.migratingProfileKeyPair()
|
||||||
|
|
||||||
proc isProfileKeyPairMigrated*(self: View): bool {.slot.} =
|
|
||||||
return self.delegate.isProfileKeyPairMigrated()
|
|
||||||
|
|
||||||
proc getSigningPhrase*(self: View): string {.slot.} =
|
proc getSigningPhrase*(self: View): string {.slot.} =
|
||||||
return self.delegate.getSigningPhrase()
|
return self.delegate.getSigningPhrase()
|
|
@ -281,7 +281,7 @@ StatusModal {
|
||||||
if (d.authenticationNeeded) {
|
if (d.authenticationNeeded) {
|
||||||
if (RootStore.loggedInUserUsesBiometricLogin())
|
if (RootStore.loggedInUserUsesBiometricLogin())
|
||||||
return "touch-id"
|
return "touch-id"
|
||||||
if (RootStore.isProfileKeyPairMigrated())
|
if (RootStore.loggedInUserIsKeycardUser())
|
||||||
return "keycard"
|
return "keycard"
|
||||||
return "password"
|
return "password"
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ QtObject {
|
||||||
return walletSectionAccounts.loggedInUserUsesBiometricLogin()
|
return walletSectionAccounts.loggedInUserUsesBiometricLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
function isProfileKeyPairMigrated() {
|
function loggedInUserIsKeycardUser() {
|
||||||
return walletSectionAccounts.isProfileKeyPairMigrated()
|
return userProfile.isKeycardUser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,9 +708,10 @@ StatusModal {
|
||||||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterSeedPhrase) {
|
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterSeedPhrase) {
|
||||||
if (root.sharedKeycardModule.loggedInUserUsesBiometricLogin())
|
if (root.sharedKeycardModule.loggedInUserUsesBiometricLogin())
|
||||||
return "touch-id"
|
return "touch-id"
|
||||||
if (root.sharedKeycardModule.isProfileKeyPairMigrated())
|
if (userProfile.isKeycardUser())
|
||||||
return "keycard"
|
return "keycard"
|
||||||
return "password"
|
return "password"
|
||||||
|
if (userProfile.isKeycardUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication) {
|
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
visible: !root.sharedKeycardModule.isProfileKeyPairMigrated()
|
visible: !userProfile.isKeycardUser
|
||||||
Layout.preferredWidth: parent.width - 2 * Style.current.padding
|
Layout.preferredWidth: parent.width - 2 * Style.current.padding
|
||||||
Layout.leftMargin: Style.current.padding
|
Layout.leftMargin: Style.current.padding
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
|
@ -70,7 +70,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPairList {
|
KeyPairList {
|
||||||
visible: !root.sharedKeycardModule.isProfileKeyPairMigrated()
|
visible: !userProfile.isKeycardUser
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 100
|
Layout.preferredHeight: 100
|
||||||
Layout.fillHeight: visible && root.sharedKeycardModule.keyPairModel.count === 1
|
Layout.fillHeight: visible && root.sharedKeycardModule.keyPairModel.count === 1
|
||||||
|
@ -88,8 +88,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
visible: root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 0 ||
|
visible: userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 0 ||
|
||||||
!root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 1
|
!userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 1
|
||||||
Layout.preferredWidth: parent.width - 2 * Style.current.padding
|
Layout.preferredWidth: parent.width - 2 * Style.current.padding
|
||||||
Layout.leftMargin: Style.current.padding
|
Layout.leftMargin: Style.current.padding
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
|
@ -100,8 +100,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPairList {
|
KeyPairList {
|
||||||
visible: root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 0 ||
|
visible: userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 0 ||
|
||||||
!root.sharedKeycardModule.isProfileKeyPairMigrated() && root.sharedKeycardModule.keyPairModel.count > 1
|
!userProfile.isKeycardUser && root.sharedKeycardModule.keyPairModel.count > 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
|
|
Loading…
Reference in New Issue