Skip to content

Commit

Permalink
Onboarding: Unblock with seedphrase flow for login
Browse files Browse the repository at this point in the history
Closes: #17142
  • Loading branch information
micieslak committed Jan 30, 2025
1 parent b3b8b38 commit 728acfe
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 37 deletions.
2 changes: 2 additions & 0 deletions storybook/pages/OnboardingLayoutPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import QtQuick.Window 2.15

import Qt.labs.settings 1.0

import StatusQ 0.1

import AppLayouts.Onboarding.enums 1.0
import AppLayouts.Onboarding2 1.0
import AppLayouts.Onboarding2.pages 1.0
Expand Down
35 changes: 3 additions & 32 deletions ui/app/AppLayouts/Onboarding2/LoginWithKeycardFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ SQUtils.QObject {
required property var tryToSetPinFunction
required property int remainingPinAttempts
required property int remainingPukAttempts
required property var isSeedPhraseValid

required property int keycardPinInfoPageDelay

property bool displayKeycardPromoBanner

signal keycardPinEntered(string pin)
signal keycardPinCreated(string pin)
signal seedphraseSubmitted(string seedphrase)
signal reloadKeycardRequested
signal keycardFactoryResetRequested
signal unblockWithSeedphraseRequested
signal unblockWithPukRequested
signal createProfileWithEmptyKeycardRequested
signal finished
Expand Down Expand Up @@ -66,7 +64,7 @@ SQUtils.QObject {

onReloadKeycardRequested: d.reload()
onKeycardFactoryResetRequested: root.keycardFactoryResetRequested()
onUnblockWithSeedphraseRequested: root.stackView.push(seedphrasePage)
onUnblockWithSeedphraseRequested: root.unblockWithSeedphraseRequested()
onUnblockWithPukRequested: root.unblockWithPukRequested()
onEmptyKeycardDetected: root.stackView.replace(keycardEmptyPage)
onNotEmptyKeycardDetected: root.stackView.replace(keycardEnterPinPage)
Expand Down Expand Up @@ -101,34 +99,7 @@ SQUtils.QObject {

onReloadKeycardRequested: d.reload()
onKeycardFactoryResetRequested: root.keycardFactoryResetRequested()
onUnblockWithSeedphraseRequested: root.stackView.push(seedphrasePage)
}
}

Component {
id: seedphrasePage

SeedphrasePage {
title: qsTr("Unblock Keycard using the recovery phrase")
btnContinueText: qsTr("Unblock Keycard")
isSeedPhraseValid: root.isSeedPhraseValid
onSeedphraseSubmitted: (seedphrase) => {
root.seedphraseSubmitted(seedphrase)
root.stackView.push(keycardCreatePinPage)
}
}
}

Component {
id: keycardCreatePinPage

KeycardCreatePinPage {
onKeycardPinCreated: (pin) => {
Backpressure.debounce(root, root.keycardPinInfoPageDelay, () => {
root.keycardPinCreated(pin)
root.finished()
})()
}
onUnblockWithSeedphraseRequested: root.unblockWithSeedphraseRequested()
}
}
}
29 changes: 24 additions & 5 deletions ui/app/AppLayouts/Onboarding2/OnboardingFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ SQUtils.QObject {
onOnboardingCreateProfileFlowRequested: root.stackView.push(createProfilePage)
onOnboardingLoginFlowRequested: root.stackView.push(loginPage)
onLostKeycard: root.stackView.push(keycardLostPage)
onUnblockWithSeedphraseRequested: console.warn("!!! FIXME OnboardingLayout::onUnblockWithSeedphraseRequested")
onUnblockWithSeedphraseRequested: unblockWithSeedphraseFlow.init()
onUnblockWithPukRequested: unblockWithPukFlow.init()
onKeycardFactoryResetRequested: console.warn("!!! FIXME OnboardingLayout::onKeycardFactoryResetRequested")

Expand Down Expand Up @@ -299,16 +299,13 @@ SQUtils.QObject {
remainingPukAttempts: root.remainingPukAttempts
displayKeycardPromoBanner: root.displayKeycardPromoBanner
tryToSetPinFunction: root.tryToSetPinFunction
isSeedPhraseValid: root.isSeedPhraseValid

keycardPinInfoPageDelay: root.keycardPinInfoPageDelay

onKeycardPinEntered: (pin) => root.keycardPinEntered(pin)
onKeycardPinCreated: (pin) => root.keycardPinCreated(pin)
onSeedphraseSubmitted: (seedphrase) => root.seedphraseSubmitted(seedphrase)
onReloadKeycardRequested: root.reloadKeycardRequested()
onCreateProfileWithEmptyKeycardRequested: keycardCreateProfileFlow.init()
onKeycardFactoryResetRequested: root.keycardFactoryResetRequested()
onUnblockWithSeedphraseRequested: unblockWithSeedphraseFlow.init()
onUnblockWithPukRequested: unblockWithPukFlow.init()

onFinished: {
Expand All @@ -317,6 +314,28 @@ SQUtils.QObject {
}
}

UnblockWithSeedphraseFlow {
id: unblockWithSeedphraseFlow

stackView: root.stackView

isSeedPhraseValid: root.isSeedPhraseValid
keycardPinInfoPageDelay: root.keycardPinInfoPageDelay

onSeedphraseSubmitted: (seedphrase) => root.seedphraseSubmitted(seedphrase)
onKeycardPinCreated: (pin) => {
root.keycardPinCreated(pin)

if (root.loginScreen) {
root.loginRequested(root.loginScreen.selectedProfileKeyId,
Onboarding.LoginMethod.Keycard, { pin })
} else {
d.flow = Onboarding.SecondaryFlow.LoginWithKeycard
d.pushOrSkipBiometricsPage()
}
}
}

UnblockWithPukFlow {
id: unblockWithPukFlow

Expand Down
52 changes: 52 additions & 0 deletions ui/app/AppLayouts/Onboarding2/UnblockWithSeedphraseFlow.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

import StatusQ.Controls 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
import StatusQ.Core.Backpressure 0.1

import AppLayouts.Onboarding2.pages 1.0
import AppLayouts.Onboarding.enums 1.0

SQUtils.QObject {
id: root

required property StackView stackView

required property var isSeedPhraseValid
required property int keycardPinInfoPageDelay

signal seedphraseSubmitted(string seedphrase)
signal keycardPinCreated(string pin)

function init() {
root.stackView.push(seedphrasePage)
}

Component {
id: seedphrasePage

SeedphrasePage {
title: qsTr("Unblock Keycard using the recovery phrase")
btnContinueText: qsTr("Unblock Keycard")
isSeedPhraseValid: root.isSeedPhraseValid
onSeedphraseSubmitted: (seedphrase) => {
root.seedphraseSubmitted(seedphrase)
root.stackView.push(keycardCreatePinPage)
}
}
}

Component {
id: keycardCreatePinPage

KeycardCreatePinPage {
onKeycardPinCreated: (pin) => {
Backpressure.debounce(root, root.keycardPinInfoPageDelay, () => {
root.keycardPinCreated(pin)
})()
}
}
}
}
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Onboarding2/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ OnboardingLayout 1.0 OnboardingLayout.qml
OnboardingStackView 1.0 OnboardingStackView.qml
RecoveryPhraseCreateProfileFlow 1.0 RecoveryPhraseCreateProfileFlow.qml
UnblockWithPukFlow 1.0 UnblockWithPukFlow.qml
UnblockWithSeedphraseFlow 1.0 UnblockWithSeedphraseFlow.qml
UseRecoveryPhraseFlow 1.0 UseRecoveryPhraseFlow.qml

0 comments on commit 728acfe

Please sign in to comment.