fix: Instance admin not updating when email added via env variable (#37568)
Using feature flagged function to evict cache to ensure correct cache line gets evicted depending on the flag ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes https://github.com/appsmithorg/appsmith/issues/33741 ## Automation /test all ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > 🔴 🔴 🔴 Some tests have failed. > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11914552417> > Commit: d4aed1f340e907c588f156d83c32e67c1ab4da18 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11914552417&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank">Cypress dashboard</a>. > Tags: @tag.All > Spec: > The following are new failures, please fix them before merging the PR: <ol> > <li>cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.js > <li>cypress/e2e/Regression/ClientSide/Github/EnableGithub_spec.ts</ol> > <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">List of identified flaky tests</a>. > <hr>Tue, 19 Nov 2024 15:04:20 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced migration functionalities for database schema updates and permission management. - Added methods for managing SSL settings for MSSQL datasources and updating Oracle plugin configurations. - Improved query performance with the creation of new indexes. - **Bug Fixes** - Updated permission management for super users and system themes, ensuring proper access. - **Chores** - Minor formatting adjustments and import updates for code clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
0420c5da87
commit
a5013ebd64
|
|
@ -28,6 +28,7 @@ import com.appsmith.server.dtos.Permission;
|
|||
import com.appsmith.server.helpers.TextUtils;
|
||||
import com.appsmith.server.migrations.solutions.UpdateSuperUserMigrationHelper;
|
||||
import com.appsmith.server.repositories.CacheableRepositoryHelper;
|
||||
import com.appsmith.server.repositories.PermissionGroupRepository;
|
||||
import com.appsmith.server.solutions.PolicySolution;
|
||||
import com.github.cloudyrock.mongock.ChangeLog;
|
||||
import com.github.cloudyrock.mongock.ChangeSet;
|
||||
|
|
@ -446,14 +447,11 @@ public class DatabaseChangelog2 {
|
|||
/**
|
||||
* Changing the order of this function to 10000 so that it always gets executed at the end.
|
||||
* This ensures that any permission changes for super users happen once all other migrations are completed
|
||||
*
|
||||
* @param mongoTemplate
|
||||
* @param cacheableRepositoryHelper
|
||||
*/
|
||||
@ChangeSet(order = "10000", id = "update-super-users", author = "", runAlways = true)
|
||||
public void updateSuperUsers(
|
||||
MongoTemplate mongoTemplate,
|
||||
CacheableRepositoryHelper cacheableRepositoryHelper,
|
||||
PermissionGroupRepository permissionGroupRepository,
|
||||
PolicySolution policySolution,
|
||||
PolicyGenerator policyGenerator) {
|
||||
// Read the admin emails from the environment and update the super users accordingly
|
||||
|
|
@ -499,7 +497,7 @@ public class DatabaseChangelog2 {
|
|||
|
||||
Set<String> oldSuperUsers = instanceAdminPG.getAssignedToUserIds();
|
||||
Set<String> updatedUserIds = findSymmetricDiff(oldSuperUsers, userIds);
|
||||
evictPermissionCacheForUsers(updatedUserIds, mongoTemplate, cacheableRepositoryHelper);
|
||||
evictPermissionCacheForUsers(updatedUserIds, mongoTemplate, permissionGroupRepository);
|
||||
|
||||
Update update = new Update().set(PermissionGroup.Fields.assignedToUserIds, userIds);
|
||||
mongoTemplate.updateFirst(permissionGroupQuery, update, PermissionGroup.class);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.appsmith.server.dtos.ApplicationJson;
|
|||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.helpers.CollectionUtils;
|
||||
import com.appsmith.server.repositories.CacheableRepositoryHelper;
|
||||
import com.appsmith.server.repositories.PermissionGroupRepository;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
|
@ -211,7 +211,7 @@ public class MigrationHelperMethods {
|
|||
}
|
||||
|
||||
public static void evictPermissionCacheForUsers(
|
||||
Set<String> userIds, MongoTemplate mongoTemplate, CacheableRepositoryHelper cacheableRepositoryHelper) {
|
||||
Set<String> userIds, MongoTemplate mongoTemplate, PermissionGroupRepository permissionGroupRepository) {
|
||||
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
// Nothing to do here.
|
||||
|
|
@ -223,8 +223,8 @@ public class MigrationHelperMethods {
|
|||
User user = mongoTemplate.findOne(query, User.class);
|
||||
if (user != null) {
|
||||
// blocking call for cache eviction to ensure its subscribed immediately before proceeding further.
|
||||
cacheableRepositoryHelper
|
||||
.evictPermissionGroupsUser(user.getEmail(), user.getTenantId())
|
||||
permissionGroupRepository
|
||||
.evictAllPermissionGroupCachesForUser(user.getEmail(), user.getTenantId())
|
||||
.block();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user