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

Commit 9dd9daf

Browse files
authored
Merge pull request #6022 from matrix-org/t3chguy/fix/16622
Fix shield icon in Untrusted Device Dialog
2 parents cad173e + 5feb9e8 commit 9dd9daf

File tree

6 files changed

+124
-54
lines changed

6 files changed

+124
-54
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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Copyright 2019, 2020, 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+
import React from "react";
18+
import { User } from "matrix-js-sdk/src/models/user";
19+
20+
import { _t } from "../../../languageHandler";
21+
import { MatrixClientPeg } from "../../../MatrixClientPeg";
22+
import E2EIcon from "../rooms/E2EIcon";
23+
import AccessibleButton from "../elements/AccessibleButton";
24+
import BaseDialog from "./BaseDialog";
25+
import { IDialogProps } from "./IDialogProps";
26+
import { IDevice } from "../right_panel/UserInfo";
27+
28+
interface IProps extends IDialogProps {
29+
user: User;
30+
device: IDevice;
31+
}
32+
33+
const UntrustedDeviceDialog: React.FC<IProps> = ({device, user, onFinished}) => {
34+
let askToVerifyText;
35+
let newSessionText;
36+
37+
if (MatrixClientPeg.get().getUserId() === user.userId) {
38+
newSessionText = _t("You signed in to a new session without verifying it:");
39+
askToVerifyText = _t("Verify your other session using one of the options below.");
40+
} else {
41+
newSessionText = _t("%(name)s (%(userId)s) signed in to a new session without verifying it:",
42+
{name: user.displayName, userId: user.userId});
43+
askToVerifyText = _t("Ask this user to verify their session, or manually verify it below.");
44+
}
45+
46+
return <BaseDialog
47+
onFinished={onFinished}
48+
className="mx_UntrustedDeviceDialog"
49+
title={<>
50+
<E2EIcon status="warning" size={24} hideTooltip={true} />
51+
{ _t("Not Trusted")}
52+
</>}
53+
>
54+
<div className="mx_Dialog_content" id='mx_Dialog_content'>
55+
<p>{newSessionText}</p>
56+
<p>{device.getDisplayName()} ({device.deviceId})</p>
57+
<p>{askToVerifyText}</p>
58+
</div>
59+
<div className='mx_Dialog_buttons'>
60+
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("legacy")}>
61+
{ _t("Manually Verify by Text") }
62+
</AccessibleButton>
63+
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("sas")}>
64+
{ _t("Interactively verify by Emoji") }
65+
</AccessibleButton>
66+
<AccessibleButton kind="primary" onClick={() => onFinished(false)}>
67+
{ _t("Done") }
68+
</AccessibleButton>
69+
</div>
70+
</BaseDialog>;
71+
};
72+
73+
export default UntrustedDeviceDialog;

src/components/views/right_panel/UserInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import RoomAvatar from "../avatars/RoomAvatar";
6767
import RoomName from "../elements/RoomName";
6868
import {mediaFromMxc} from "../../../customisations/Media";
6969

70-
interface IDevice {
70+
export interface IDevice {
7171
deviceId: string;
7272
ambiguous?: boolean;
7373
getDisplayName(): string;

src/i18n/strings/en_EN.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,6 @@
578578
"%(senderName)s updated a ban rule that was matching %(oldGlob)s to matching %(newGlob)s for %(reason)s": "%(senderName)s updated a ban rule that was matching %(oldGlob)s to matching %(newGlob)s for %(reason)s",
579579
"Light": "Light",
580580
"Dark": "Dark",
581-
"You signed in to a new session without verifying it:": "You signed in to a new session without verifying it:",
582-
"Verify your other session using one of the options below.": "Verify your other session using one of the options below.",
583-
"%(name)s (%(userId)s) signed in to a new session without verifying it:": "%(name)s (%(userId)s) signed in to a new session without verifying it:",
584-
"Ask this user to verify their session, or manually verify it below.": "Ask this user to verify their session, or manually verify it below.",
585-
"Not Trusted": "Not Trusted",
586-
"Manually Verify by Text": "Manually Verify by Text",
587-
"Interactively verify by Emoji": "Interactively verify by Emoji",
588-
"Done": "Done",
589581
"%(displayName)s is typing …": "%(displayName)s is typing …",
590582
"%(names)s and %(count)s others are typing …|other": "%(names)s and %(count)s others are typing …",
591583
"%(names)s and %(count)s others are typing …|one": "%(names)s and one other is typing …",
@@ -2067,6 +2059,7 @@
20672059
"Close dialog": "Close dialog",
20682060
"Beta feedback": "Beta feedback",
20692061
"Thank you for your feedback, we really appreciate it.": "Thank you for your feedback, we really appreciate it.",
2062+
"Done": "Done",
20702063
"%(featureName)s beta feedback": "%(featureName)s beta feedback",
20712064
"Your platform and username will be noted to help us use your feedback as much as we can.": "Your platform and username will be noted to help us use your feedback as much as we can.",
20722065
"To leave the beta, visit your settings.": "To leave the beta, visit your settings.",
@@ -2390,6 +2383,13 @@
23902383
"Summary": "Summary",
23912384
"Document": "Document",
23922385
"Next": "Next",
2386+
"You signed in to a new session without verifying it:": "You signed in to a new session without verifying it:",
2387+
"Verify your other session using one of the options below.": "Verify your other session using one of the options below.",
2388+
"%(name)s (%(userId)s) signed in to a new session without verifying it:": "%(name)s (%(userId)s) signed in to a new session without verifying it:",
2389+
"Ask this user to verify their session, or manually verify it below.": "Ask this user to verify their session, or manually verify it below.",
2390+
"Not Trusted": "Not Trusted",
2391+
"Manually Verify by Text": "Manually Verify by Text",
2392+
"Interactively verify by Emoji": "Interactively verify by Emoji",
23932393
"Upload files (%(current)s of %(total)s)": "Upload files (%(current)s of %(total)s)",
23942394
"Upload files": "Upload files",
23952395
"Upload all": "Upload all",

src/verification.js renamed to src/verification.ts

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
2+
Copyright 2019, 2020, 2021 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -14,16 +14,19 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import {MatrixClientPeg} from './MatrixClientPeg';
17+
import { User } from "matrix-js-sdk/src/models/user";
18+
19+
import { MatrixClientPeg } from './MatrixClientPeg';
1820
import dis from "./dispatcher/dispatcher";
1921
import Modal from './Modal';
2022
import * as sdk from './index';
21-
import { _t } from './languageHandler';
22-
import {RightPanelPhases} from "./stores/RightPanelStorePhases";
23-
import {findDMForUser} from './createRoom';
24-
import {accessSecretStorage} from './SecurityManager';
25-
import {verificationMethods} from 'matrix-js-sdk/src/crypto';
26-
import {Action} from './dispatcher/actions';
23+
import { RightPanelPhases } from "./stores/RightPanelStorePhases";
24+
import { findDMForUser } from './createRoom';
25+
import { accessSecretStorage } from './SecurityManager';
26+
import { verificationMethods } from 'matrix-js-sdk/src/crypto';
27+
import { Action } from './dispatcher/actions';
28+
import UntrustedDeviceDialog from "./components/views/dialogs/UntrustedDeviceDialog";
29+
import {IDevice} from "./components/views/right_panel/UserInfo";
2730

2831
async function enable4SIfNeeded() {
2932
const cli = MatrixClientPeg.get();
@@ -39,40 +42,7 @@ async function enable4SIfNeeded() {
3942
return true;
4043
}
4144

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-
75-
export async function verifyDevice(user, device) {
45+
export async function verifyDevice(user: User, device: IDevice) {
7646
const cli = MatrixClientPeg.get();
7747
if (cli.isGuest()) {
7848
dis.dispatch({action: 'require_registration'});
@@ -115,7 +85,7 @@ export async function verifyDevice(user, device) {
11585
});
11686
}
11787

118-
export async function legacyVerifyUser(user) {
88+
export async function legacyVerifyUser(user: User) {
11989
const cli = MatrixClientPeg.get();
12090
if (cli.isGuest()) {
12191
dis.dispatch({action: 'require_registration'});
@@ -135,7 +105,7 @@ export async function legacyVerifyUser(user) {
135105
});
136106
}
137107

138-
export async function verifyUser(user) {
108+
export async function verifyUser(user: User) {
139109
const cli = MatrixClientPeg.get();
140110
if (cli.isGuest()) {
141111
dis.dispatch({action: 'require_registration'});
@@ -155,7 +125,7 @@ export async function verifyUser(user) {
155125
});
156126
}
157127

158-
export function pendingVerificationRequestForUser(user) {
128+
export function pendingVerificationRequestForUser(user: User) {
159129
const cli = MatrixClientPeg.get();
160130
const dmRoom = findDMForUser(cli, user.userId);
161131
if (dmRoom) {

0 commit comments

Comments
 (0)