fix: small onboarding/login fixes and feats
- fix: Change displayed login key to whisper public key (starts with 0x04) - fix: remove key displayed on login accounts as this value is not passed to use from status-go's openAccounts - feat: add selected account view when entering password for login and generating an account (same UI as importing a key)
This commit is contained in:
parent
691717990d
commit
ac37f0fdbb
|
@ -26,10 +26,10 @@ proc init*(self: LoginController, nodeAccounts: seq[NodeAccount]) =
|
|||
|
||||
proc handleNodeLogin(self: LoginController, data: Signal) =
|
||||
let response = NodeSignal(data)
|
||||
if self.status.accounts.currentLoginAccount != nil:
|
||||
if self.view.currentAccount.account != nil:
|
||||
self.view.setLastLoginResponse(response.event)
|
||||
if ?.response.event.error == "":
|
||||
self.status.events.emit("login", AccountArgs(account: self.status.accounts.currentLoginAccount))
|
||||
self.status.events.emit("login", AccountArgs(account: self.view.currentAccount.account.toAccount))
|
||||
|
||||
method onSignal(self: LoginController, data: Signal) =
|
||||
if data.signalType == SignalType.NodeLogin:
|
||||
|
|
|
@ -9,20 +9,20 @@ import ../../signals/types
|
|||
import ../../status/libstatus/types as status_types
|
||||
import ../../status/libstatus/accounts as status_accounts
|
||||
import ../../status/accounts as AccountModel
|
||||
|
||||
import ../onboarding/views/account_info
|
||||
import ../../status/status
|
||||
import core
|
||||
|
||||
type
|
||||
AccountRoles {.pure.} = enum
|
||||
Username = UserRole + 1,
|
||||
Identicon = UserRole + 2,
|
||||
Key = UserRole + 3
|
||||
Identicon = UserRole + 2
|
||||
|
||||
QtObject:
|
||||
type LoginView* = ref object of QAbstractListModel
|
||||
status: Status
|
||||
accounts: seq[NodeAccount]
|
||||
currentAccount*: AccountInfoView
|
||||
|
||||
proc setup(self: LoginView) =
|
||||
self.QAbstractListModel.setup
|
||||
|
@ -34,6 +34,7 @@ QtObject:
|
|||
proc newLoginView*(status: Status): LoginView =
|
||||
new(result, delete)
|
||||
result.accounts = @[]
|
||||
result.currentAccount = newAccountInfoView()
|
||||
result.status = status
|
||||
result.setup
|
||||
|
||||
|
@ -56,12 +57,21 @@ QtObject:
|
|||
case assetRole:
|
||||
of AccountRoles.Username: result = newQVariant(asset.name)
|
||||
of AccountRoles.Identicon: result = newQVariant(asset.photoPath)
|
||||
of AccountRoles.Key: result = newQVariant(asset.keyUid)
|
||||
|
||||
method roleNames(self: LoginView): Table[int, string] =
|
||||
{ AccountRoles.Username.int:"username",
|
||||
AccountRoles.Identicon.int:"identicon",
|
||||
AccountRoles.Key.int:"key" }.toTable
|
||||
AccountRoles.Identicon.int:"identicon" }.toTable
|
||||
|
||||
proc getCurrentAccount*(self: LoginView): QVariant {.slot.} =
|
||||
result = newQVariant(self.currentAccount)
|
||||
|
||||
proc setCurrentAccount*(self: LoginView, selectedAccountIdx: int) {.slot.} =
|
||||
let currNodeAcct = self.accounts[selectedAccountIdx]
|
||||
self.currentAccount.setAccount(GeneratedAccount(name: currNodeAcct.name, photoPath: currNodeAcct.photoPath))
|
||||
|
||||
QtProperty[QVariant] currentAccount:
|
||||
read = getCurrentAccount
|
||||
write = setCurrentAccount
|
||||
|
||||
proc login(self: LoginView, selectedAccountIndex: int, password: string): string {.slot.} =
|
||||
try:
|
||||
|
|
|
@ -31,10 +31,10 @@ proc init*(self: OnboardingController) =
|
|||
|
||||
proc handleNodeLogin(self: OnboardingController, data: Signal) =
|
||||
let response = NodeSignal(data)
|
||||
if self.status.accounts.currentOnboardingAccount != nil:
|
||||
if self.view.currentAccount.account != nil:
|
||||
self.view.setLastLoginResponse(response.event)
|
||||
if ?.response.event.error == "":
|
||||
self.status.events.emit("login", AccountArgs(account: self.status.accounts.currentOnboardingAccount))
|
||||
self.status.events.emit("login", AccountArgs(account: self.view.currentAccount.account.toAccount))
|
||||
|
||||
method onSignal(self: OnboardingController, data: Signal) =
|
||||
if data.signalType == SignalType.NodeLogin:
|
||||
|
|
|
@ -19,7 +19,7 @@ type
|
|||
QtObject:
|
||||
type OnboardingView* = ref object of QAbstractListModel
|
||||
accounts*: seq[GeneratedAccount]
|
||||
importedAccount: AccountInfoView
|
||||
currentAccount*: AccountInfoView
|
||||
status*: Status
|
||||
|
||||
proc setup(self: OnboardingView) =
|
||||
|
@ -32,7 +32,7 @@ QtObject:
|
|||
proc newOnboardingView*(status: Status): OnboardingView =
|
||||
new(result, delete)
|
||||
result.accounts = @[]
|
||||
result.importedAccount = newAccountInfoView()
|
||||
result.currentAccount = newAccountInfoView()
|
||||
result.status = status
|
||||
result.setup
|
||||
|
||||
|
@ -55,7 +55,7 @@ QtObject:
|
|||
case assetRole:
|
||||
of AccountRoles.Username: result = newQVariant(asset.name)
|
||||
of AccountRoles.Identicon: result = newQVariant(asset.photoPath)
|
||||
of AccountRoles.Key: result = newQVariant(asset.derived.whisper.address)
|
||||
of AccountRoles.Key: result = newQVariant(asset.derived.whisper.publicKey)
|
||||
|
||||
method roleNames(self: OnboardingView): Table[int, string] =
|
||||
{ AccountRoles.Username.int:"username",
|
||||
|
@ -71,26 +71,27 @@ QtObject:
|
|||
msg = getCurrentExceptionMsg()
|
||||
result = StatusGoError(error: msg).toJson
|
||||
|
||||
proc getImportedAccount*(self: OnboardingView): QVariant {.slot.} =
|
||||
result = newQVariant(self.importedAccount)
|
||||
proc getCurrentAccount*(self: OnboardingView): QVariant {.slot.} =
|
||||
result = newQVariant(self.currentAccount)
|
||||
|
||||
proc setImportedAccount*(self: OnboardingView, importedAccount: GeneratedAccount) =
|
||||
self.importedAccount.setAccount(importedAccount)
|
||||
proc setCurrentAccount*(self: OnboardingView, selectedAccountIdx: int) {.slot.} =
|
||||
self.currentAccount.setAccount(self.accounts[selectedAccountIdx])
|
||||
|
||||
QtProperty[QVariant] importedAccount:
|
||||
read = getImportedAccount
|
||||
QtProperty[QVariant] currentAccount:
|
||||
read = getCurrentAccount
|
||||
write = setCurrentAccount
|
||||
|
||||
proc importMnemonic(self: OnboardingView, mnemonic: string): string {.slot.} =
|
||||
try:
|
||||
let importResult = self.status.accounts.importMnemonic(mnemonic)
|
||||
result = importResult.toJson
|
||||
self.setImportedAccount(importResult)
|
||||
self.currentAccount.setAccount(importResult)
|
||||
except StatusGoException as e:
|
||||
result = StatusGoError(error: e.msg).toJson
|
||||
|
||||
proc storeDerivedAndLogin(self: OnboardingView, password: string): string {.slot.} =
|
||||
try:
|
||||
result = self.status.accounts.storeDerivedAndLogin(self.importedAccount.account, password).toJson
|
||||
result = self.status.accounts.storeDerivedAndLogin(self.currentAccount.account, password).toJson
|
||||
except StatusGoException as e:
|
||||
var msg = e.msg
|
||||
if e.msg.contains("account already exists"):
|
||||
|
|
|
@ -6,13 +6,9 @@ type
|
|||
AccountModel* = ref object
|
||||
generatedAddresses*: seq[GeneratedAccount]
|
||||
nodeAccounts*: seq[NodeAccount]
|
||||
currentLoginAccount*: Account
|
||||
currentOnboardingAccount*: Account
|
||||
|
||||
proc newAccountModel*(): AccountModel =
|
||||
result = AccountModel()
|
||||
result.currentLoginAccount = nil
|
||||
result.currentOnboardingAccount = nil
|
||||
|
||||
proc generateAddresses*(self: AccountModel): seq[GeneratedAccount] =
|
||||
var accounts = status_accounts.generateAddresses()
|
||||
|
@ -24,17 +20,14 @@ proc generateAddresses*(self: AccountModel): seq[GeneratedAccount] =
|
|||
|
||||
proc login*(self: AccountModel, selectedAccountIndex: int, password: string): NodeAccount =
|
||||
let currentNodeAccount = self.nodeAccounts[selectedAccountIndex]
|
||||
self.currentLoginAccount = currentNodeAccount.toAccount
|
||||
result = status_accounts.login(currentNodeAccount, password)
|
||||
|
||||
proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, password: string): Account =
|
||||
let generatedAccount: GeneratedAccount = self.generatedAddresses[selectedAccountIndex]
|
||||
result = status_accounts.setupAccount(generatedAccount, password)
|
||||
self.currentOnboardingAccount = generatedAccount.toAccount
|
||||
|
||||
proc storeDerivedAndLogin*(self: AccountModel, importedAccount: GeneratedAccount, password: string): Account =
|
||||
result = status_accounts.setupAccount(importedAccount, password)
|
||||
self.currentOnboardingAccount = importedAccount.toAccount
|
||||
|
||||
proc importMnemonic*(self: AccountModel, mnemonic: string): GeneratedAccount =
|
||||
let importedAccount = status_accounts.multiAccountImportMnemonic(mnemonic)
|
||||
|
|
|
@ -77,15 +77,15 @@ SwipeView {
|
|||
anchors.topMargin: 30
|
||||
Column {
|
||||
Image {
|
||||
source: onboardingModel.importedAccount.identicon
|
||||
source: onboardingModel.currentAccount.identicon
|
||||
}
|
||||
}
|
||||
Column {
|
||||
Text {
|
||||
text: onboardingModel.importedAccount.username
|
||||
text: onboardingModel.currentAccount.username
|
||||
}
|
||||
Text {
|
||||
text: onboardingModel.importedAccount.address
|
||||
text: onboardingModel.currentAccount.address
|
||||
width: 160
|
||||
elide: Text.ElideMiddle
|
||||
}
|
||||
|
@ -141,15 +141,15 @@ SwipeView {
|
|||
anchors.topMargin: 30
|
||||
Column {
|
||||
Image {
|
||||
source: onboardingModel.importedAccount.identicon
|
||||
source: onboardingModel.currentAccount.identicon
|
||||
}
|
||||
}
|
||||
Column {
|
||||
Text {
|
||||
text: onboardingModel.importedAccount.username
|
||||
text: onboardingModel.currentAccount.username
|
||||
}
|
||||
Text {
|
||||
text: onboardingModel.importedAccount.address
|
||||
text: onboardingModel.currentAccount.address
|
||||
width: 160
|
||||
elide: Text.ElideMiddle
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@ SwipeView {
|
|||
label: "Select"
|
||||
|
||||
onClicked: {
|
||||
onboardingModel.setCurrentAccount(wizardStep1.selectedIndex)
|
||||
swipeView.incrementCurrentIndex()
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +125,7 @@ SwipeView {
|
|||
property Item txtPassword: txtPassword
|
||||
|
||||
Text {
|
||||
id: step2Title
|
||||
text: "Enter password"
|
||||
font.pointSize: 36
|
||||
anchors.top: parent.top
|
||||
|
@ -131,6 +133,28 @@ SwipeView {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: step2Title.bottom
|
||||
anchors.topMargin: 30
|
||||
Column {
|
||||
Image {
|
||||
source: onboardingModel.currentAccount.identicon
|
||||
}
|
||||
}
|
||||
Column {
|
||||
Text {
|
||||
text: onboardingModel.currentAccount.username
|
||||
}
|
||||
Text {
|
||||
text: onboardingModel.currentAccount.address
|
||||
width: 160
|
||||
elide: Text.ElideMiddle
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Input {
|
||||
id: txtPassword
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
@ -165,6 +189,7 @@ SwipeView {
|
|||
property Item txtPassword: txtConfirmPassword
|
||||
|
||||
Text {
|
||||
id: step3Title
|
||||
text: "Confirm password"
|
||||
font.pointSize: 36
|
||||
anchors.top: parent.top
|
||||
|
@ -172,6 +197,28 @@ SwipeView {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: step3Title.bottom
|
||||
anchors.topMargin: 30
|
||||
Column {
|
||||
Image {
|
||||
source: onboardingModel.currentAccount.identicon
|
||||
}
|
||||
}
|
||||
Column {
|
||||
Text {
|
||||
text: onboardingModel.currentAccount.username
|
||||
}
|
||||
Text {
|
||||
text: onboardingModel.currentAccount.address
|
||||
width: 160
|
||||
elide: Text.ElideMiddle
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Input {
|
||||
id: txtConfirmPassword
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
|
@ -66,11 +66,6 @@ SwipeView {
|
|||
Text {
|
||||
text: username
|
||||
}
|
||||
Text {
|
||||
text: key
|
||||
width: 160
|
||||
elide: Text.ElideMiddle
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +112,7 @@ SwipeView {
|
|||
label: "Select"
|
||||
|
||||
onClicked: {
|
||||
loginModel.setCurrentAccount(wizardStep1.selectedIndex)
|
||||
swipeView.incrementCurrentIndex()
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +124,7 @@ SwipeView {
|
|||
property Item txtPassword: txtPassword
|
||||
|
||||
Text {
|
||||
id: step2Title
|
||||
text: "Enter password"
|
||||
font.pointSize: 36
|
||||
anchors.top: parent.top
|
||||
|
@ -135,6 +132,22 @@ SwipeView {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: step2Title.bottom
|
||||
anchors.topMargin: 30
|
||||
Column {
|
||||
Image {
|
||||
source: loginModel.currentAccount.identicon
|
||||
}
|
||||
}
|
||||
Column {
|
||||
Text {
|
||||
text: loginModel.currentAccount.username
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Input {
|
||||
id: txtPassword
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
Loading…
Reference in New Issue