From 34a577d63dddce8a259cf323122f0afbc9300ca5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 16 Sep 2024 10:46:51 +0200 Subject: [PATCH] Temporary account creation flow is only supported on matrix.org --- .../impl/web/WebClientUrlForAuthenticationRetriever.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/web/WebClientUrlForAuthenticationRetriever.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/web/WebClientUrlForAuthenticationRetriever.kt index 9955fe150d..0f5375bde4 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/web/WebClientUrlForAuthenticationRetriever.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/web/WebClientUrlForAuthenticationRetriever.kt @@ -9,11 +9,13 @@ package io.element.android.features.login.impl.web import android.net.Uri import com.squareup.anvil.annotations.ContributesBinding +import io.element.android.appconfig.AuthenticationConfig import io.element.android.features.login.impl.resolver.network.WellknownAPI import io.element.android.features.login.impl.screens.createaccount.AccountCreationNotSupported import io.element.android.libraries.di.AppScope import io.element.android.libraries.network.RetrofitFactory import java.net.HttpURLConnection +import timber.log.Timber import javax.inject.Inject interface WebClientUrlForAuthenticationRetriever { @@ -25,6 +27,10 @@ class DefaultWebClientUrlForAuthenticationRetriever @Inject constructor( private val retrofitFactory: RetrofitFactory, ) : WebClientUrlForAuthenticationRetriever { override suspend fun retrieve(homeServerUrl: String): String { + if (homeServerUrl != AuthenticationConfig.MATRIX_ORG_URL) { + Timber.w("Temporary account creation flow is only supported on matrix.org") + throw AccountCreationNotSupported() + } val wellknownApi = retrofitFactory.create(homeServerUrl) .create(WellknownAPI::class.java) val result = try {