2021-05-12 19:04:24 +03:00
|
|
|
/*
|
2021-05-12 19:08:44 +03:00
|
|
|
Copyright 2019, 2020, 2021 The Matrix.org Foundation C.I.C.
|
2021-05-12 19:04:24 +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.
|
|
|
|
*/
|
|
|
|
|
2021-05-12 19:08:44 +03:00
|
|
|
import React from "react";
|
|
|
|
import { User } from "matrix-js-sdk/src/models/user";
|
2021-05-12 19:04:24 +03:00
|
|
|
|
2021-05-12 19:08:44 +03:00
|
|
|
import { _t } from "../../../languageHandler";
|
|
|
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
2021-05-12 19:04:24 +03:00
|
|
|
import E2EIcon from "../rooms/E2EIcon";
|
2021-05-12 19:08:44 +03:00
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
|
|
|
import BaseDialog from "./BaseDialog";
|
|
|
|
import { IDialogProps } from "./IDialogProps";
|
|
|
|
import { IDevice } from "../right_panel/UserInfo";
|
2021-05-12 19:04:24 +03:00
|
|
|
|
2021-05-12 19:08:44 +03:00
|
|
|
interface IProps extends IDialogProps {
|
|
|
|
user: User;
|
|
|
|
device: IDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
const UntrustedDeviceDialog: React.FC<IProps> = ({device, user, onFinished}) => {
|
2021-05-12 19:04:24 +03:00
|
|
|
let askToVerifyText;
|
|
|
|
let newSessionText;
|
|
|
|
|
|
|
|
if (MatrixClientPeg.get().getUserId() === user.userId) {
|
|
|
|
newSessionText = _t("You signed in to a new session without verifying it:");
|
|
|
|
askToVerifyText = _t("Verify your other session using one of the options below.");
|
|
|
|
} else {
|
|
|
|
newSessionText = _t("%(name)s (%(userId)s) signed in to a new session without verifying it:",
|
|
|
|
{name: user.displayName, userId: user.userId});
|
|
|
|
askToVerifyText = _t("Ask this user to verify their session, or manually verify it below.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return <BaseDialog
|
|
|
|
onFinished={onFinished}
|
|
|
|
className="mx_UntrustedDeviceDialog"
|
|
|
|
title={<>
|
|
|
|
<E2EIcon status="warning" size={24} hideTooltip={true} />
|
|
|
|
{ _t("Not Trusted")}
|
|
|
|
</>}
|
|
|
|
>
|
|
|
|
<div className="mx_Dialog_content" id='mx_Dialog_content'>
|
|
|
|
<p>{newSessionText}</p>
|
|
|
|
<p>{device.getDisplayName()} ({device.deviceId})</p>
|
|
|
|
<p>{askToVerifyText}</p>
|
|
|
|
</div>
|
|
|
|
<div className='mx_Dialog_buttons'>
|
2021-05-12 19:08:44 +03:00
|
|
|
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("legacy")}>
|
|
|
|
{ _t("Manually Verify by Text") }
|
|
|
|
</AccessibleButton>
|
|
|
|
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("sas")}>
|
|
|
|
{ _t("Interactively verify by Emoji") }
|
|
|
|
</AccessibleButton>
|
|
|
|
<AccessibleButton kind="primary" onClick={() => onFinished(false)}>
|
|
|
|
{ _t("Done") }
|
|
|
|
</AccessibleButton>
|
2021-05-12 19:04:24 +03:00
|
|
|
</div>
|
|
|
|
</BaseDialog>;
|
2021-05-12 19:08:44 +03:00
|
|
|
};
|
2021-05-12 19:04:24 +03:00
|
|
|
|
|
|
|
export default UntrustedDeviceDialog;
|