|
| 1 | +/* |
| 2 | +Copyright 2019, 2020 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import React from 'react'; |
| 18 | + |
| 19 | +import { _t } from '../../../languageHandler'; |
| 20 | +import * as sdk from '../../../index'; |
| 21 | +import {MatrixClientPeg} from '../../../MatrixClientPeg'; |
| 22 | +import E2EIcon from "../rooms/E2EIcon"; |
| 23 | + |
| 24 | +function UntrustedDeviceDialog(props) { |
| 25 | + const {device, user, onFinished} = props; |
| 26 | + const BaseDialog = sdk.getComponent("dialogs.BaseDialog"); |
| 27 | + const AccessibleButton = sdk.getComponent("elements.AccessibleButton"); |
| 28 | + let askToVerifyText; |
| 29 | + let newSessionText; |
| 30 | + |
| 31 | + if (MatrixClientPeg.get().getUserId() === user.userId) { |
| 32 | + newSessionText = _t("You signed in to a new session without verifying it:"); |
| 33 | + askToVerifyText = _t("Verify your other session using one of the options below."); |
| 34 | + } else { |
| 35 | + newSessionText = _t("%(name)s (%(userId)s) signed in to a new session without verifying it:", |
| 36 | + {name: user.displayName, userId: user.userId}); |
| 37 | + askToVerifyText = _t("Ask this user to verify their session, or manually verify it below."); |
| 38 | + } |
| 39 | + |
| 40 | + return <BaseDialog |
| 41 | + onFinished={onFinished} |
| 42 | + className="mx_UntrustedDeviceDialog" |
| 43 | + title={<> |
| 44 | + <E2EIcon status="warning" size={24} hideTooltip={true} /> |
| 45 | + { _t("Not Trusted")} |
| 46 | + </>} |
| 47 | + > |
| 48 | + <div className="mx_Dialog_content" id='mx_Dialog_content'> |
| 49 | + <p>{newSessionText}</p> |
| 50 | + <p>{device.getDisplayName()} ({device.deviceId})</p> |
| 51 | + <p>{askToVerifyText}</p> |
| 52 | + </div> |
| 53 | + <div className='mx_Dialog_buttons'> |
| 54 | + <AccessibleButton element="button" kind="secondary" onClick={() => onFinished("legacy")}>{_t("Manually Verify by Text")}</AccessibleButton> |
| 55 | + <AccessibleButton element="button" kind="secondary" onClick={() => onFinished("sas")}>{_t("Interactively verify by Emoji")}</AccessibleButton> |
| 56 | + <AccessibleButton kind="primary" onClick={() => onFinished()}>{_t("Done")}</AccessibleButton> |
| 57 | + </div> |
| 58 | + </BaseDialog>; |
| 59 | +} |
| 60 | + |
| 61 | +export default UntrustedDeviceDialog; |
0 commit comments