Skip to content

Commit

Permalink
Merge pull request #13202 from woocommerce/issue/13192-force-password…
Browse files Browse the repository at this point in the history
…-screen

[Login] Add ability to force using password for login even for passwordless accounts
  • Loading branch information
hichamboushaba authored Jan 16, 2025
2 parents 07de8ee + 20549d2 commit 696e505
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions WooCommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,13 @@ task copyGoogleServicesExampleFile(type: Copy) {
android.buildTypes.all { buildType ->
(secretProperties + developerProperties).any { property ->
if (property.key.toLowerCase().startsWith("wc.")) {
buildType.buildConfigField "String", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
"\"${property.value}\""
if (property.value == "true" || property.value == "false") {
buildType.buildConfigField "boolean", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
property.value
} else {
buildType.buildConfigField "String", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
"\"${property.value}\""
}
}
if (property.key.toLowerCase().startsWith("wc.res.")) {
buildType.resValue "string", property.key.replace("wc.res.", "").replace(".", "_").toLowerCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.lifecycle.withStarted
import com.woocommerce.android.AppPrefsWrapper
import com.woocommerce.android.AppUrls
import com.woocommerce.android.AppUrls.LOGIN_WITH_EMAIL_WHAT_IS_WORDPRESS_COM_ACCOUNT
import com.woocommerce.android.BuildConfig
import com.woocommerce.android.R
import com.woocommerce.android.analytics.AnalyticsEvent
import com.woocommerce.android.analytics.AnalyticsTracker
Expand Down Expand Up @@ -350,7 +351,9 @@ class LoginActivity :
clearCachedSites()

if (authOptions != null) {
if (authOptions.isPasswordless) {
val forcePasswordLogin = BuildConfig.DEBUG && BuildConfig.FORCE_PASSWORD_LOGIN

if (authOptions.isPasswordless && !forcePasswordLogin) {
showMagicLinkRequestScreen(email, verifyEmail, allowPassword = false, forceRequestAtStart = true)
} else {
showEmailPasswordScreen(email, verifyEmail)
Expand Down
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ measureBuilds {
}

static def loadPropertiesWithFallback(Logger logger, File fallbackFile, File primaryFile) {
def defaultProperties = readPropertiesFromFile(fallbackFile)
def primaryProperties
if (primaryFile.exists()) {
return readPropertiesFromFile(primaryFile)
primaryProperties = readPropertiesFromFile(primaryFile)
} else {
logger.warn("Primary properties file not found: ${primaryFile}. Using fallback: ${fallbackFile}.")
return readPropertiesFromFile(fallbackFile)
primaryProperties = new Properties()
}

return defaultProperties + primaryProperties
}

static def readPropertiesFromFile(File file) {
Expand Down
1 change: 1 addition & 0 deletions developer.properties-example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# The type of in app update FLEXIBLE = 0; IMMEDIATE = 1
wc.in_app_update_type = 0
wc.jitm_testing_json_file_name=
wc.force_password_login = false
enable_leak_canary=true

0 comments on commit 696e505

Please sign in to comment.