2020-01-28 02:14:02 +03:00
|
|
|
|
/*
|
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
import { _t } from '../../../languageHandler';
|
2020-01-28 13:10:37 +03:00
|
|
|
|
import Modal from '../../../Modal';
|
|
|
|
|
import { replaceableComponent } from '../../../utils/replaceableComponent';
|
2020-01-31 19:15:52 +03:00
|
|
|
|
import VerificationRequestDialog from './VerificationRequestDialog';
|
2020-01-28 13:10:37 +03:00
|
|
|
|
import BaseDialog from './BaseDialog';
|
|
|
|
|
import DialogButtons from '../elements/DialogButtons';
|
2020-01-30 20:50:14 +03:00
|
|
|
|
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
2020-02-25 14:34:01 +03:00
|
|
|
|
import * as sdk from '../../../index';
|
2020-01-28 02:14:02 +03:00
|
|
|
|
|
2020-01-28 13:10:37 +03:00
|
|
|
|
@replaceableComponent("views.dialogs.NewSessionReviewDialog")
|
2020-01-28 02:14:02 +03:00
|
|
|
|
export default class NewSessionReviewDialog extends React.PureComponent {
|
|
|
|
|
static propTypes = {
|
|
|
|
|
userId: PropTypes.string.isRequired,
|
|
|
|
|
device: PropTypes.object.isRequired,
|
|
|
|
|
onFinished: PropTypes.func.isRequired,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onCancelClick = () => {
|
2020-02-25 14:34:01 +03:00
|
|
|
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
|
|
|
|
Modal.createTrackedDialog("Verification failed", "insecure", ErrorDialog, {
|
|
|
|
|
headerImage: require("../../../../res/img/e2e/warning.svg"),
|
|
|
|
|
title: _t("Your account is not secure"),
|
|
|
|
|
description: <div>
|
|
|
|
|
{_t("One of the following may be compromised:")}
|
|
|
|
|
<ul>
|
|
|
|
|
<li>{_t("Your password")}</li>
|
|
|
|
|
<li>{_t("Your homeserver")}</li>
|
2020-02-25 18:40:06 +03:00
|
|
|
|
<li>{_t("This session, or the other session")}</li>
|
|
|
|
|
<li>{_t("The internet connection either session is using")}</li>
|
2020-02-25 14:34:01 +03:00
|
|
|
|
</ul>
|
|
|
|
|
<div>
|
2020-02-25 18:40:06 +03:00
|
|
|
|
{_t("We recommend you change your password and recovery key in Settings immediately")}
|
2020-02-25 14:34:01 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>,
|
|
|
|
|
onFinished: () => this.props.onFinished(false),
|
|
|
|
|
});
|
2020-01-28 02:14:02 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-10 20:59:45 +03:00
|
|
|
|
onContinueClick = () => {
|
2020-01-28 02:14:02 +03:00
|
|
|
|
const { userId, device } = this.props;
|
2020-01-30 20:50:14 +03:00
|
|
|
|
const cli = MatrixClientPeg.get();
|
2020-03-10 20:59:45 +03:00
|
|
|
|
const requestPromise = cli.requestVerification(
|
2020-01-31 14:21:49 +03:00
|
|
|
|
userId,
|
|
|
|
|
[device.deviceId],
|
|
|
|
|
);
|
2020-01-31 16:01:32 +03:00
|
|
|
|
|
2020-01-31 16:42:02 +03:00
|
|
|
|
this.props.onFinished(true);
|
2020-01-31 19:15:52 +03:00
|
|
|
|
Modal.createTrackedDialog('New Session Verification', 'Starting dialog', VerificationRequestDialog, {
|
2020-03-10 20:59:45 +03:00
|
|
|
|
verificationRequestPromise: requestPromise,
|
|
|
|
|
member: cli.getUser(userId),
|
2020-01-31 14:21:49 +03:00
|
|
|
|
});
|
2020-01-28 02:14:02 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { device } = this.props;
|
|
|
|
|
|
|
|
|
|
const icon = <span className="mx_NewSessionReviewDialog_headerIcon mx_E2EIcon_warning"></span>;
|
|
|
|
|
const titleText = _t("New session");
|
|
|
|
|
|
|
|
|
|
const title = <h2 className="mx_NewSessionReviewDialog_header">
|
|
|
|
|
{icon}
|
|
|
|
|
{titleText}
|
|
|
|
|
</h2>;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<BaseDialog
|
|
|
|
|
title={title}
|
|
|
|
|
onFinished={this.props.onFinished}
|
|
|
|
|
>
|
|
|
|
|
<div className="mx_NewSessionReviewDialog_body">
|
|
|
|
|
<p>{_t(
|
|
|
|
|
"Use this session to verify your new one, " +
|
|
|
|
|
"granting it access to encrypted messages:",
|
|
|
|
|
)}</p>
|
|
|
|
|
<div className="mx_NewSessionReviewDialog_deviceInfo">
|
|
|
|
|
<div>
|
|
|
|
|
<span className="mx_NewSessionReviewDialog_deviceName">
|
|
|
|
|
{device.getDisplayName()}
|
|
|
|
|
</span> <span className="mx_NewSessionReviewDialog_deviceID">
|
|
|
|
|
({device.deviceId})
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<p>{_t(
|
|
|
|
|
"If you didn’t sign in to this session, " +
|
|
|
|
|
"your account may be compromised.",
|
|
|
|
|
)}</p>
|
|
|
|
|
<DialogButtons
|
|
|
|
|
cancelButton={_t("This wasn't me")}
|
|
|
|
|
cancelButtonClass="danger"
|
|
|
|
|
primaryButton={_t("Continue")}
|
|
|
|
|
onCancel={this.onCancelClick}
|
|
|
|
|
onPrimaryButtonClick={this.onContinueClick}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</BaseDialog>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|