From 804866483b2d9e9a7e09a0059c5cc59200400daa Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Tue, 8 Apr 2025 12:38:31 +0530 Subject: [PATCH] chore: Enable the form login by default (#40154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description PR to provide fallback for form login state when it's not explicitly set by the user.Enable the form login by default Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Settings" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 58ecbe074e2f8b371b55542a273be80379adfc6d > Cypress dashboard. > Tags: `@tag.Settings` > Spec: >
Tue, 08 Apr 2025 07:02:34 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Enhancements** - Improved the behavior for updating organization login settings so that the correct default is consistently applied, ensuring a more reliable configuration update. - **Tests** - Added tests to verify that changes to the login setting are applied as expected, enhancing confidence in the update process. --- .../ce/OrganizationConfigurationCE.java | 9 +++- .../ce/OrganizationServiceCETest.java | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/OrganizationConfigurationCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/OrganizationConfigurationCE.java index 153447260a..415e5035dd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/OrganizationConfigurationCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/OrganizationConfigurationCE.java @@ -81,7 +81,7 @@ public class OrganizationConfigurationCE implements Serializable { googleMapsKey = ObjectUtils.defaultIfNull(organizationConfiguration.getGoogleMapsKey(), googleMapsKey); isFormLoginEnabled = - ObjectUtils.defaultIfNull(organizationConfiguration.getIsFormLoginEnabled(), isFormLoginEnabled); + getComputedValue(true, organizationConfiguration.getIsFormLoginEnabled(), isFormLoginEnabled); isSignupDisabled = ObjectUtils.defaultIfNull(organizationConfiguration.getIsSignupDisabled(), isSignupDisabled); instanceName = ObjectUtils.defaultIfNull(organizationConfiguration.getInstanceName(), instanceName); emailVerificationEnabled = ObjectUtils.defaultIfNull( @@ -93,6 +93,13 @@ public class OrganizationConfigurationCE implements Serializable { isAtomicPushAllowed = organizationConfiguration.getIsAtomicPushAllowed(); } + protected static T getComputedValue(T defaultValue, T updatedValue, T currentValue) { + if (currentValue == null && updatedValue == null) { + return defaultValue; + } + return ObjectUtils.defaultIfNull(updatedValue, currentValue); + } + public static class Fields { public Fields() { // Public constructor for Fields class diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/OrganizationServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/OrganizationServiceCETest.java index e6434a9b58..5df36a2270 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/OrganizationServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/OrganizationServiceCETest.java @@ -172,6 +172,49 @@ class OrganizationServiceCETest { .verify(); } + @Test + @WithUserDetails("api_user") + void updateOrganizationConfiguration_updateFormLoginEnabled_success() { + + // Ensure that default value for form login is enabled + Mono organizationMono = organizationService.getOrganizationConfiguration(); + StepVerifier.create(organizationMono) + .assertNext(organization -> { + assertThat(organization.getOrganizationConfiguration().getIsFormLoginEnabled()) + .isTrue(); + }) + .verifyComplete(); + + // Ensure that the form login is disabled after the update + final OrganizationConfiguration changes = new OrganizationConfiguration(); + changes.setIsFormLoginEnabled(FALSE); + Mono resultMono = organizationService + .updateOrganizationConfiguration(changes) + .then(organizationService.getOrganizationConfiguration()) + .map(Organization::getOrganizationConfiguration); + + StepVerifier.create(resultMono) + .assertNext(organizationConfiguration -> { + assertThat(organizationConfiguration.getIsFormLoginEnabled()) + .isFalse(); + }) + .verifyComplete(); + + // Ensure that the form login is enabled after the update + changes.setIsFormLoginEnabled(TRUE); + resultMono = organizationService + .updateOrganizationConfiguration(changes) + .then(organizationService.getOrganizationConfiguration()) + .map(Organization::getOrganizationConfiguration); + + StepVerifier.create(resultMono) + .assertNext(organizationConfiguration -> { + assertThat(organizationConfiguration.getIsFormLoginEnabled()) + .isTrue(); + }) + .verifyComplete(); + } + @Test @WithUserDetails("anonymousUser") void getOrganizationConfig_Valid_AnonymousUser() {