Fix upgrading with already trusted backup

This commit is contained in:
David Baker 2020-05-29 15:55:16 +01:00
parent f54bac0e95
commit 631184c661

View file

@ -68,7 +68,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
// does the server offer a UI auth flow with just m.login.password // does the server offer a UI auth flow with just m.login.password
// for /keys/device_signing/upload? (If we have an account password, we // for /keys/device_signing/upload? (If we have an account password, we
// assume that it can) // assume that it can)
canUploadKeysWithPasswordOnly: Boolean(this.state.accountPassword), canUploadKeysWithPasswordOnly: null,
canUploadKeyCheckInProgress: false, canUploadKeyCheckInProgress: false,
accountPassword: props.accountPassword || "", accountPassword: props.accountPassword || "",
accountPasswordCorrect: null, accountPasswordCorrect: null,
@ -76,6 +76,12 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
useKeyBackup: true, useKeyBackup: true,
}; };
if (props.accountPassword) {
// If we have an account password, we assume we can upload keys with
// just a password (otherwise leave it as null so we poll to check)
this.state.canUploadKeysWithPasswordOnly = true;
}
this._passphraseField = createRef(); this._passphraseField = createRef();
this.loadData(); this.loadData();
@ -375,7 +381,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
<div>{_t("Restore your key backup to upgrade your encryption")}</div> <div>{_t("Restore your key backup to upgrade your encryption")}</div>
</div>; </div>;
nextCaption = _t("Restore"); nextCaption = _t("Restore");
} else if (this.state.canUploadKeysWithPasswordOnly && !this.state.accountPassword) { } else if (this.state.canUploadKeysWithPasswordOnly && !this.props.accountPassword) {
authPrompt = <div> authPrompt = <div>
<div>{_t("Enter your account password to confirm the upgrade:")}</div> <div>{_t("Enter your account password to confirm the upgrade:")}</div>
<div><Field <div><Field