From a7fdade61a7e8e30b4185f35f370526b62f4aa51 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Wed, 9 Sep 2026 16:12:45 +0200 Subject: [PATCH] Tolerate a registration flow that carries no params `registerRequest({})` rejects with the registration flows, and a homeserver may answer with no `params` at all, which threw a TypeError on the landing and login screens and left them without a privacy policy link. Co-Authored-By: Claude Fable 5.1 --- src/auth/useInteractiveRegistration.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/auth/useInteractiveRegistration.ts b/src/auth/useInteractiveRegistration.ts index 7314c9e4a..7346cf172 100644 --- a/src/auth/useInteractiveRegistration.ts +++ b/src/auth/useInteractiveRegistration.ts @@ -50,11 +50,16 @@ export const useInteractiveRegistration = ( useEffect(() => { if (isWidget) return; // An empty registerRequest is used to get the privacy policy and recaptcha key. + // A 401 carrying the flow parameters is the expected answer, so this + // rejection is the success path, and some homeservers answer it with no + // params at all. authClient.current!.registerRequest({}).catch((error) => { + logger.debug("Registration flow parameters", error); setPrivacyPolicyUrl( - error.data?.params["m.login.terms"]?.policies?.privacy_policy?.en?.url, + error.data?.params?.["m.login.terms"]?.policies?.privacy_policy?.en + ?.url, ); - setRecaptchaKey(error.data?.params["m.login.recaptcha"]?.public_key); + setRecaptchaKey(error.data?.params?.["m.login.recaptcha"]?.public_key); }); }, [isWidget]);