mirror of https://github.com/vector-im/riot-web
Enable key backup by default
When we set up cross signing, so the key backup key will be stored locally along with the cross signing keys until the user sets up recovery (4s). This will mean that a user can restore their backup if they log in on a new device as long as they verify with the one they registered on.dbkr/key_backup_by_default
parent
d4cf3881bc
commit
2c7247713a
|
@ -11,7 +11,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|||
|
||||
import AuthPage from "../../views/auth/AuthPage";
|
||||
import CompleteSecurityBody from "../../views/auth/CompleteSecurityBody";
|
||||
import CreateCrossSigningDialog from "../../views/dialogs/security/CreateCrossSigningDialog";
|
||||
import InitialCryptoSetup from "../../views/dialogs/security/InitialCryptoSetup";
|
||||
|
||||
interface IProps {
|
||||
matrixClient: MatrixClient;
|
||||
|
@ -25,7 +25,7 @@ export default class E2eSetup extends React.Component<IProps> {
|
|||
return (
|
||||
<AuthPage>
|
||||
<CompleteSecurityBody>
|
||||
<CreateCrossSigningDialog
|
||||
<InitialCryptoSetup
|
||||
matrixClient={this.props.matrixClient}
|
||||
onFinished={this.props.onFinished}
|
||||
accountPassword={this.props.accountPassword}
|
||||
|
|
|
@ -25,14 +25,14 @@ interface Props {
|
|||
}
|
||||
|
||||
/*
|
||||
* Walks the user through the process of creating a cross-signing keys. In most
|
||||
* cases, only a spinner is shown, but for more complex auth like SSO, the user
|
||||
* may need to complete some steps to proceed.
|
||||
* Walks the user through the process of creating a cross-signing keys and setting
|
||||
* up message key backup. In most cases, only a spinner is shown, but for more
|
||||
* complex auth like SSO, the user may need to complete some steps to proceed.
|
||||
*/
|
||||
const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => {
|
||||
const InitialCryptoSetup: React.FC<Props> = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => {
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
const bootstrapCrossSigning = useCallback(async () => {
|
||||
const doSetup = useCallback(async () => {
|
||||
const cryptoApi = matrixClient.getCrypto();
|
||||
if (!cryptoApi) return;
|
||||
|
||||
|
@ -40,6 +40,12 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
|||
|
||||
try {
|
||||
await createCrossSigning(matrixClient, tokenLogin, accountPassword);
|
||||
|
||||
const backupInfo = await matrixClient.getKeyBackupVersion();
|
||||
if (backupInfo === null) {
|
||||
await cryptoApi.resetKeyBackup();
|
||||
}
|
||||
|
||||
onFinished(true);
|
||||
} catch (e) {
|
||||
if (tokenLogin) {
|
||||
|
@ -58,8 +64,8 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
|||
}, [onFinished]);
|
||||
|
||||
useEffect(() => {
|
||||
bootstrapCrossSigning();
|
||||
}, [bootstrapCrossSigning]);
|
||||
doSetup();
|
||||
}, [doSetup]);
|
||||
|
||||
let content;
|
||||
if (error) {
|
||||
|
@ -69,7 +75,7 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
|||
<div className="mx_Dialog_buttons">
|
||||
<DialogButtons
|
||||
primaryButton={_t("action|retry")}
|
||||
onPrimaryButtonClick={bootstrapCrossSigning}
|
||||
onPrimaryButtonClick={doSetup}
|
||||
onCancel={onCancel}
|
||||
/>
|
||||
</div>
|
||||
|
@ -96,4 +102,4 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
|||
);
|
||||
};
|
||||
|
||||
export default CreateCrossSigningDialog;
|
||||
export default InitialCryptoSetup;
|
Loading…
Reference in New Issue