Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 565e41c

Browse files
committed
Extract UntrustedDeviceDialog and fix e2ee icon
1 parent 5d02e44 commit 565e41c

File tree

4 files changed

+89
-34
lines changed

4 files changed

+89
-34
lines changed

res/css/_components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
@import "./views/dialogs/_SpaceSettingsDialog.scss";
9999
@import "./views/dialogs/_TabbedIntegrationManagerDialog.scss";
100100
@import "./views/dialogs/_TermsDialog.scss";
101+
@import "./views/dialogs/_UntrustedDeviceDialog.scss";
101102
@import "./views/dialogs/_UploadConfirmDialog.scss";
102103
@import "./views/dialogs/_UserSettingsDialog.scss";
103104
@import "./views/dialogs/_WidgetCapabilitiesPromptDialog.scss";
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2021 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+
.mx_UntrustedDeviceDialog {
18+
.mx_Dialog_title {
19+
display: flex;
20+
align-items: center;
21+
22+
.mx_E2EIcon {
23+
margin-left: 0;
24+
}
25+
}
26+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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;

src/verification.js

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import {MatrixClientPeg} from './MatrixClientPeg';
1818
import dis from "./dispatcher/dispatcher";
1919
import Modal from './Modal';
2020
import * as sdk from './index';
21-
import { _t } from './languageHandler';
2221
import {RightPanelPhases} from "./stores/RightPanelStorePhases";
2322
import {findDMForUser} from './createRoom';
2423
import {accessSecretStorage} from './SecurityManager';
2524
import {verificationMethods} from 'matrix-js-sdk/src/crypto';
2625
import {Action} from './dispatcher/actions';
26+
import UntrustedDeviceDialog from "./components/views/dialogs/UntrustedDeviceDialog";
2727

2828
async function enable4SIfNeeded() {
2929
const cli = MatrixClientPeg.get();
@@ -39,39 +39,6 @@ async function enable4SIfNeeded() {
3939
return true;
4040
}
4141

42-
function UntrustedDeviceDialog(props) {
43-
const {device, user, onFinished} = props;
44-
const BaseDialog = sdk.getComponent("dialogs.BaseDialog");
45-
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
46-
let askToVerifyText;
47-
let newSessionText;
48-
49-
if (MatrixClientPeg.get().getUserId() === user.userId) {
50-
newSessionText = _t("You signed in to a new session without verifying it:");
51-
askToVerifyText = _t("Verify your other session using one of the options below.");
52-
} else {
53-
newSessionText = _t("%(name)s (%(userId)s) signed in to a new session without verifying it:",
54-
{name: user.displayName, userId: user.userId});
55-
askToVerifyText = _t("Ask this user to verify their session, or manually verify it below.");
56-
}
57-
58-
return <BaseDialog
59-
onFinished={onFinished}
60-
headerImage={require("../res/img/e2e/warning.svg")}
61-
title={_t("Not Trusted")}>
62-
<div className="mx_Dialog_content" id='mx_Dialog_content'>
63-
<p>{newSessionText}</p>
64-
<p>{device.getDisplayName()} ({device.deviceId})</p>
65-
<p>{askToVerifyText}</p>
66-
</div>
67-
<div className='mx_Dialog_buttons'>
68-
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("legacy")}>{_t("Manually Verify by Text")}</AccessibleButton>
69-
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("sas")}>{_t("Interactively verify by Emoji")}</AccessibleButton>
70-
<AccessibleButton kind="primary" onClick={() => onFinished()}>{_t("Done")}</AccessibleButton>
71-
</div>
72-
</BaseDialog>;
73-
}
74-
7542
export async function verifyDevice(user, device) {
7643
const cli = MatrixClientPeg.get();
7744
if (cli.isGuest()) {

0 commit comments

Comments
 (0)