Differentiate between E2EE and non-E2EE rooms by alias presence

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2023-08-11 17:00:05 +02:00
parent edfae0138c
commit 22690c4a0b
3 changed files with 55 additions and 13 deletions

View File

@@ -40,9 +40,11 @@ import styles from "./UnauthenticatedView.module.css";
import commonStyles from "./common.module.css";
import { generateRandomName } from "../auth/generateRandomName";
import { AnalyticsNotice } from "../analytics/AnalyticsNotice";
import { useOptInAnalytics } from "../settings/useSetting";
import { useEnableE2EE, useOptInAnalytics } from "../settings/useSetting";
import { Config } from "../config/Config";
import { E2EEBanner } from "../E2EEBanner";
import { getRoomSharedKeyLocalStorageKey } from "../e2ee/sharedKeyManagement";
import { setLocalStorageItem } from "../useLocalStorage";
export const UnauthenticatedView: FC = () => {
const { setClient } = useClient();
@@ -58,6 +60,8 @@ export const UnauthenticatedView: FC = () => {
const history = useHistory();
const { t } = useTranslation();
const [e2eeEnabled] = useEnableE2EE();
const onSubmit: FormEventHandler<HTMLFormElement> = useCallback(
(e) => {
e.preventDefault();
@@ -79,9 +83,18 @@ export const UnauthenticatedView: FC = () => {
true
);
let roomAlias: string;
let roomId: string;
try {
[roomAlias] = await createRoom(client, roomName, ptt);
roomId = (
await createRoom(client, roomName, ptt, e2eeEnabled ?? false)
)[1];
if (e2eeEnabled) {
setLocalStorageItem(
getRoomSharedKeyLocalStorageKey(roomId),
randomString(32)
);
}
} catch (error) {
if (!setClient) {
throw error;
@@ -120,7 +133,16 @@ export const UnauthenticatedView: FC = () => {
reset();
});
},
[register, reset, execute, history, callType, modalState, setClient]
[
register,
reset,
execute,
history,
callType,
modalState,
setClient,
e2eeEnabled,
]
);
const callNameLabel =