diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 7aaedcfb09..b5b77e3ae6 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -1900,10 +1900,12 @@ export default class MatrixChat extends React.PureComponent { return setLoggedInPromise; } - // Test for the master cross-signing key in SSSS as a quick proxy for - // whether cross-signing has been set up on the account. - const masterKeyInStorage = !!cli.getAccountData("m.cross_signing.master"); - if (masterKeyInStorage) { + // wait for the client to finish downloading cross-signing keys for us so we + // know whether or not we have keys set up on this account + await cli.downloadKeys([cli.getUserId()]); + + const crossSigningIsSetUp = cli.getStoredCrossSigningForUser(cli.getUserId()); + if (crossSigningIsSetUp) { this.setStateForNewView({ view: Views.COMPLETE_SECURITY }); } else if (await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")) { this.setStateForNewView({ view: Views.E2E_SETUP }); diff --git a/src/components/structures/auth/SetupEncryptionBody.js b/src/components/structures/auth/SetupEncryptionBody.js index 7886ed26dd..4cc5c5ef75 100644 --- a/src/components/structures/auth/SetupEncryptionBody.js +++ b/src/components/structures/auth/SetupEncryptionBody.js @@ -16,7 +16,7 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; -import { _t } from '../../../languageHandler'; +import { _t, _td } from '../../../languageHandler'; import { MatrixClientPeg } from '../../../MatrixClientPeg'; import * as sdk from '../../../index'; import withValidation from '../../views/elements/Validation'; @@ -196,11 +196,27 @@ export default class SetupEncryptionBody extends React.Component { } else if (phase === PHASE_INTRO) { const store = SetupEncryptionStore.sharedInstance(); let recoveryKeyPrompt; - if (keyHasPassphrase(store.keyInfo)) { + if (store.keyInfo && keyHasPassphrase(store.keyInfo)) { recoveryKeyPrompt = _t("Use Recovery Key or Passphrase"); - } else { + } else if (store.keyInfo) { recoveryKeyPrompt = _t("Use Recovery Key"); } + + let useRecoveryKeyButton; + let resetKeysCaption; + if (recoveryKeyPrompt) { + useRecoveryKeyButton = + {recoveryKeyPrompt} + ; + resetKeysCaption = _td( + "If you've forgotten your recovery key you can ", + ); + } else { + resetKeysCaption = _td( + "If you have no other devices you can ", + ); + } + return (

{_t( @@ -224,16 +240,12 @@ export default class SetupEncryptionBody extends React.Component {

- - {recoveryKeyPrompt} - + {useRecoveryKeyButton} {_t("Skip")}
-
{_t( - "If you've forgotten your recovery key you can " + - "", {}, { +
{_t(resetKeysCaption, {}, { button: sub => diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index e54a4d8662..416d1debe7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2101,6 +2101,7 @@ "Looks good!": "Looks good!", "Use Recovery Key or Passphrase": "Use Recovery Key or Passphrase", "Use Recovery Key": "Use Recovery Key", + "If you have no other devices you can ": "If you have no other devices you can ", "Confirm your identity by verifying this login from one of your other sessions, granting it access to encrypted messages.": "Confirm your identity by verifying this login from one of your other sessions, granting it access to encrypted messages.", "This requires the latest Riot on your other devices:": "This requires the latest Riot on your other devices:", "or another cross-signing capable Matrix client": "or another cross-signing capable Matrix client", diff --git a/src/stores/SetupEncryptionStore.js b/src/stores/SetupEncryptionStore.js index cc64e24a03..e155a5c29f 100644 --- a/src/stores/SetupEncryptionStore.js +++ b/src/stores/SetupEncryptionStore.js @@ -68,7 +68,7 @@ export class SetupEncryptionStore extends EventEmitter { async fetchKeyInfo() { const keys = await MatrixClientPeg.get().isSecretStored('m.cross_signing.master', false); - if (Object.keys(keys).length === 0) { + if (!keys || Object.keys(keys).length === 0) { this.keyId = null; this.keyInfo = null; } else {