From 6539c15177c836089a2c90b596cd2ecbeea2b442 Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:07:44 +0100 Subject: [PATCH] Dont send register request in widget mode (#2100) * dont register in widget mode Signed-off-by: Timo K * not call registerPasswordlessUser where its called in a widget. Signed-off-by: Timo K --------- Signed-off-by: Timo K --- src/auth/useRegisterPasswordlessUser.ts | 6 ++++++ src/room/RoomPage.tsx | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/auth/useRegisterPasswordlessUser.ts b/src/auth/useRegisterPasswordlessUser.ts index d34a479e..44f2132f 100644 --- a/src/auth/useRegisterPasswordlessUser.ts +++ b/src/auth/useRegisterPasswordlessUser.ts @@ -21,6 +21,7 @@ import { useClient } from "../ClientContext"; import { useInteractiveRegistration } from "../auth/useInteractiveRegistration"; import { generateRandomName } from "../auth/generateRandomName"; import { useRecaptcha } from "../auth/useRecaptcha"; +import { widget } from "../widget"; interface UseRegisterPasswordlessUserType { privacyPolicyUrl?: string; @@ -39,6 +40,11 @@ export function useRegisterPasswordlessUser(): UseRegisterPasswordlessUserType { if (!setClient) { throw new Error("No client context"); } + if (widget) { + throw new Error( + "Registration was skipped: We should never try to register password-less user in embedded mode.", + ); + } try { const recaptchaResponse = await execute(); diff --git a/src/room/RoomPage.tsx b/src/room/RoomPage.tsx index 3ae11b50..0e93b547 100644 --- a/src/room/RoomPage.tsx +++ b/src/room/RoomPage.tsx @@ -29,6 +29,7 @@ import { useOptInAnalytics } from "../settings/useSetting"; import { HomePage } from "../home/HomePage"; import { platform } from "../Platform"; import { AppSelectionModal } from "./AppSelectionModal"; +import { widget } from "../widget"; export const RoomPage: FC = () => { const { @@ -62,7 +63,7 @@ export const RoomPage: FC = () => { useEffect(() => { // If we've finished loading, are not already authed and we've been given a display name as // a URL param, automatically register a passwordless user - if (!loading && !authenticated && displayName) { + if (!loading && !authenticated && displayName && !widget) { setIsRegistering(true); registerPasswordlessUser(displayName).finally(() => { setIsRegistering(false);