2018-12-13 18:55:48 +03:00
|
|
|
/*
|
2020-01-03 16:33:32 +03:00
|
|
|
Copyright 2018, 2019 New Vector Ltd
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
2018-12-13 18:55:48 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
2019-12-20 04:19:56 +03:00
|
|
|
import * as sdk from "../../../../index";
|
2019-12-21 00:13:46 +03:00
|
|
|
import {MatrixClientPeg} from '../../../../MatrixClientPeg';
|
2018-12-13 18:55:48 +03:00
|
|
|
import dis from "../../../../dispatcher";
|
|
|
|
import { _t } from "../../../../languageHandler";
|
|
|
|
import Modal from "../../../../Modal";
|
|
|
|
|
|
|
|
export default class NewRecoveryMethodDialog extends React.PureComponent {
|
|
|
|
static propTypes = {
|
2019-01-11 16:15:09 +03:00
|
|
|
// As returned by js-sdk getKeyBackupVersion()
|
2019-01-11 21:39:16 +03:00
|
|
|
newVersionInfo: PropTypes.object,
|
2018-12-13 18:55:48 +03:00
|
|
|
onFinished: PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
2019-01-11 16:15:09 +03:00
|
|
|
onOkClick = () => {
|
|
|
|
this.props.onFinished();
|
|
|
|
}
|
|
|
|
|
2018-12-13 18:55:48 +03:00
|
|
|
onGoToSettingsClick = () => {
|
|
|
|
this.props.onFinished();
|
|
|
|
dis.dispatch({ action: 'view_user_settings' });
|
|
|
|
}
|
|
|
|
|
2019-01-09 21:10:35 +03:00
|
|
|
onSetupClick = async () => {
|
2019-02-11 19:41:06 +03:00
|
|
|
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
|
2020-01-03 16:33:32 +03:00
|
|
|
Modal.createTrackedDialog(
|
|
|
|
'Restore Backup', '', RestoreKeyBackupDialog, {
|
|
|
|
onFinished: this.props.onFinished,
|
|
|
|
}, null, /* priority = */ false, /* static = */ true,
|
|
|
|
);
|
2018-12-13 18:55:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const BaseDialog = sdk.getComponent("views.dialogs.BaseDialog");
|
|
|
|
const DialogButtons = sdk.getComponent("views.elements.DialogButtons");
|
2019-01-11 00:13:44 +03:00
|
|
|
|
|
|
|
const title = <span className="mx_KeyBackupFailedDialog_title">
|
2018-12-13 18:55:48 +03:00
|
|
|
{_t("New Recovery Method")}
|
|
|
|
</span>;
|
|
|
|
|
2019-01-11 16:15:09 +03:00
|
|
|
const newMethodDetected = <p>{_t(
|
|
|
|
"A new recovery passphrase and key for Secure " +
|
|
|
|
"Messages have been detected.",
|
|
|
|
)}</p>;
|
|
|
|
|
|
|
|
const hackWarning = <p className="warning">{_t(
|
|
|
|
"If you didn't set the new recovery method, an " +
|
|
|
|
"attacker may be trying to access your account. " +
|
|
|
|
"Change your account password and set a new recovery " +
|
|
|
|
"method immediately in Settings.",
|
|
|
|
)}</p>;
|
|
|
|
|
|
|
|
let content;
|
|
|
|
if (MatrixClientPeg.get().getKeyBackupEnabled()) {
|
|
|
|
content = <div>
|
|
|
|
{newMethodDetected}
|
|
|
|
<p>{_t(
|
2020-01-29 18:48:25 +03:00
|
|
|
"This session is encrypting history using the new recovery method.",
|
2019-01-11 16:15:09 +03:00
|
|
|
)}</p>
|
|
|
|
{hackWarning}
|
|
|
|
<DialogButtons
|
|
|
|
primaryButton={_t("OK")}
|
|
|
|
onPrimaryButtonClick={this.onOkClick}
|
|
|
|
cancelButton={_t("Go to Settings")}
|
|
|
|
onCancel={this.onGoToSettingsClick}
|
|
|
|
/>
|
|
|
|
</div>;
|
|
|
|
} else {
|
|
|
|
content = <div>
|
|
|
|
{newMethodDetected}
|
|
|
|
{hackWarning}
|
|
|
|
<DialogButtons
|
|
|
|
primaryButton={_t("Set up Secure Messages")}
|
|
|
|
onPrimaryButtonClick={this.onSetupClick}
|
|
|
|
cancelButton={_t("Go to Settings")}
|
|
|
|
onCancel={this.onGoToSettingsClick}
|
|
|
|
/>
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
|
2018-12-13 18:55:48 +03:00
|
|
|
return (
|
2019-01-11 00:13:44 +03:00
|
|
|
<BaseDialog className="mx_KeyBackupFailedDialog"
|
2018-12-13 18:55:48 +03:00
|
|
|
onFinished={this.props.onFinished}
|
|
|
|
title={title}
|
|
|
|
>
|
2019-01-11 16:15:09 +03:00
|
|
|
{content}
|
2018-12-13 18:55:48 +03:00
|
|
|
</BaseDialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|