Change passphrase working

This commit is contained in:
Zach Fox 2017-10-03 10:53:10 -07:00
parent 11d0062104
commit e64b0861a1
4 changed files with 20 additions and 12 deletions

View file

@ -90,7 +90,7 @@ Item {
} else {
// Error submitting new passphrase
resetSubmitButton();
passphraseSelection.setErrorText("Backend error");
passphraseSelection.setErrorText("Current passphrase incorrect - try again");
}
} else {
sendSignalToWallet(msg);
@ -137,9 +137,10 @@ Item {
width: 150;
text: "Submit";
onClicked: {
if (passphraseSelection.validateAndSubmitPassphrase()) {
passphraseSubmitButton.text = "Submitting...";
passphraseSubmitButton.enabled = false;
passphraseSubmitButton.text = "Submitting...";
passphraseSubmitButton.enabled = false;
if (!passphraseSelection.validateAndSubmitPassphrase()) {
resetSubmitButton();
}
}
}

View file

@ -43,8 +43,8 @@ Item {
passphrasePageSecurityImage.source = "image://security/securityImage";
}
onWalletAuthenticatedStatusResult: {
sendMessageToLightbox({method: 'statusResult', status: isAuthenticated});
onChangePassphraseStatusResult: {
sendMessageToLightbox({method: 'statusResult', status: changeSuccess});
}
}
@ -310,7 +310,7 @@ Item {
passphraseFieldAgain.error = false;
currentPassphraseField.error = false;
setErrorText("");
commerce.setPassphrase(passphraseField.text);
commerce.changePassphrase(currentPassphraseField.text, passphraseField.text);
return true;
}
}

View file

@ -117,13 +117,18 @@ void QmlCommerce::history() {
ledger->history(wallet->listPublicKeys());
}
void QmlCommerce::changePassphrase(const QString& oldPassphrase, const QString& newPassphrase) {
auto wallet = DependencyManager::get<Wallet>();
if ((wallet->getPassphrase()->isEmpty() || wallet->getPassphrase() == oldPassphrase) && !newPassphrase.isEmpty()) {
emit changePassphraseStatusResult(wallet->changePassphrase(newPassphrase));
} else {
emit changePassphraseStatusResult(false);
}
}
void QmlCommerce::setPassphrase(const QString& passphrase) {
auto wallet = DependencyManager::get<Wallet>();
if(wallet->getPassphrase() && !wallet->getPassphrase()->isEmpty() && !passphrase.isEmpty()) {
wallet->changePassphrase(passphrase);
} else {
wallet->setPassphrase(passphrase);
}
wallet->setPassphrase(passphrase);
getWalletAuthenticatedStatus();
}

View file

@ -41,6 +41,7 @@ signals:
void keyFilePathIfExistsResult(const QString& path);
void securityImageResult(bool exists);
void walletAuthenticatedStatusResult(bool isAuthenticated);
void changePassphraseStatusResult(bool changeSuccess);
void buyResult(QJsonObject result);
// Balance and Inventory are NOT properties, because QML can't change them (without risk of failure), and
@ -60,6 +61,7 @@ protected:
Q_INVOKABLE void chooseSecurityImage(const QString& imageFile);
Q_INVOKABLE void setPassphrase(const QString& passphrase);
Q_INVOKABLE void changePassphrase(const QString& oldPassphrase, const QString& newPassphrase);
Q_INVOKABLE void buy(const QString& assetId, int cost, const bool controlledFailure = false);
Q_INVOKABLE void balance();