Skip to content

Commit 696e505

Browse files
Merge pull request #13202 from woocommerce/issue/13192-force-password-screen
[Login] Add ability to force using password for login even for passwordless accounts
2 parents 07de8ee + 20549d2 commit 696e505

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

WooCommerce/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,13 @@ task copyGoogleServicesExampleFile(type: Copy) {
489489
android.buildTypes.all { buildType ->
490490
(secretProperties + developerProperties).any { property ->
491491
if (property.key.toLowerCase().startsWith("wc.")) {
492-
buildType.buildConfigField "String", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
493-
"\"${property.value}\""
492+
if (property.value == "true" || property.value == "false") {
493+
buildType.buildConfigField "boolean", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
494+
property.value
495+
} else {
496+
buildType.buildConfigField "String", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
497+
"\"${property.value}\""
498+
}
494499
}
495500
if (property.key.toLowerCase().startsWith("wc.res.")) {
496501
buildType.resValue "string", property.key.replace("wc.res.", "").replace(".", "_").toLowerCase(),

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.lifecycle.withStarted
1515
import com.woocommerce.android.AppPrefsWrapper
1616
import com.woocommerce.android.AppUrls
1717
import com.woocommerce.android.AppUrls.LOGIN_WITH_EMAIL_WHAT_IS_WORDPRESS_COM_ACCOUNT
18+
import com.woocommerce.android.BuildConfig
1819
import com.woocommerce.android.R
1920
import com.woocommerce.android.analytics.AnalyticsEvent
2021
import com.woocommerce.android.analytics.AnalyticsTracker
@@ -350,7 +351,9 @@ class LoginActivity :
350351
clearCachedSites()
351352

352353
if (authOptions != null) {
353-
if (authOptions.isPasswordless) {
354+
val forcePasswordLogin = BuildConfig.DEBUG && BuildConfig.FORCE_PASSWORD_LOGIN
355+
356+
if (authOptions.isPasswordless && !forcePasswordLogin) {
354357
showMagicLinkRequestScreen(email, verifyEmail, allowPassword = false, forceRequestAtStart = true)
355358
} else {
356359
showEmailPasswordScreen(email, verifyEmail)

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ measureBuilds {
4141
}
4242

4343
static def loadPropertiesWithFallback(Logger logger, File fallbackFile, File primaryFile) {
44+
def defaultProperties = readPropertiesFromFile(fallbackFile)
45+
def primaryProperties
4446
if (primaryFile.exists()) {
45-
return readPropertiesFromFile(primaryFile)
47+
primaryProperties = readPropertiesFromFile(primaryFile)
4648
} else {
4749
logger.warn("Primary properties file not found: ${primaryFile}. Using fallback: ${fallbackFile}.")
48-
return readPropertiesFromFile(fallbackFile)
50+
primaryProperties = new Properties()
4951
}
52+
53+
return defaultProperties + primaryProperties
5054
}
5155

5256
static def readPropertiesFromFile(File file) {

developer.properties-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# The type of in app update FLEXIBLE = 0; IMMEDIATE = 1
22
wc.in_app_update_type = 0
33
wc.jitm_testing_json_file_name=
4+
wc.force_password_login = false
45
enable_leak_canary=true

0 commit comments

Comments
 (0)