diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt index 10a3c09e5c5..82f573be081 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt @@ -56,6 +56,7 @@ import com.woocommerce.android.util.ChromeCustomTabUtils import com.woocommerce.android.util.ChromeCustomTabUtils.Height.Partial.ThreeQuarters import com.woocommerce.android.util.UrlUtils import com.woocommerce.android.util.WooLog +import com.woocommerce.android.util.getBuildConfigValueOrNull import dagger.android.AndroidInjector import dagger.android.DispatchingAndroidInjector import dagger.android.HasAndroidInjector @@ -351,7 +352,8 @@ class LoginActivity : clearCachedSites() if (authOptions != null) { - val forcePasswordLogin = BuildConfig.DEBUG && BuildConfig.FORCE_PASSWORD_LOGIN + val forcePasswordLogin = BuildConfig.DEBUG && + getBuildConfigValueOrNull("FORCE_PASSWORD_LOGIN") == true if (authOptions.isPasswordless && !forcePasswordLogin) { showMagicLinkRequestScreen(email, verifyEmail, allowPassword = false, forceRequestAtStart = true) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/BuildConfigExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/BuildConfigExt.kt new file mode 100644 index 00000000000..61694d64210 --- /dev/null +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/BuildConfigExt.kt @@ -0,0 +1,13 @@ +package com.woocommerce.android.util + +import com.woocommerce.android.BuildConfig + +@Suppress("SwallowedException") +inline fun getBuildConfigValueOrNull(key: String): T? { + return try { + val field = BuildConfig::class.java.getField(key) + field.get(null) as? T + } catch (e: NoSuchFileException) { + null + } +}