cloud-ide-core 2.0.83 → 2.0.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12170,9 +12170,11 @@ class CideCoreUserCreateComponent {
12170
12170
  * - If modified !== actual: create/update exception
12171
12171
  * - If modified === actual BUT exception exists in DB: delete exception
12172
12172
  * - If modified === actual AND no exception exists: do nothing
12173
+ * - Also process all existing exceptions from DB to ensure nothing is missed
12173
12174
  */
12174
12175
  processRoleExceptions() {
12175
12176
  const exceptions = [];
12177
+ const processedExceptionKeys = new Set(); // Track processed exceptions to avoid duplicates
12176
12178
  console.log('🎭 Processing role exceptions for all entity mappings...');
12177
12179
  // Iterate through all entity mappings
12178
12180
  this.entityMappings().forEach((mapping, mappingIndex) => {
@@ -12185,6 +12187,9 @@ class CideCoreUserCreateComponent {
12185
12187
  const permissionData = menu?._permissionValues?.[permissionId] || {};
12186
12188
  // Find existing exception for this menu/permission combination
12187
12189
  const existingException = this.findExistingException(this.userId() || '', mapping._id || '', permissionId, menu._id || '');
12190
+ // Create a unique key for this exception
12191
+ const exceptionKey = `${mapping._id || ''}_${menu._id || ''}_${permissionId}`;
12192
+ processedExceptionKeys.add(exceptionKey);
12188
12193
  // Check if permission was modified (different from actual role permission)
12189
12194
  if (permissionData.modified !== permissionData.actual) {
12190
12195
  // Create or update exception
@@ -12228,6 +12233,39 @@ class CideCoreUserCreateComponent {
12228
12233
  });
12229
12234
  }
12230
12235
  });
12236
+ // Also check all existing exceptions from DB that might not be in current menu rights
12237
+ // This ensures we don't miss any exceptions that should be deleted
12238
+ existingExceptions.forEach((existingException) => {
12239
+ if (existingException._id) {
12240
+ const exceptionKey = `${existingException.syusrex_user_entity_mapping_id_syenm || ''}_${existingException.syusrex_menu_id_syme || ''}_${existingException.syusrex_role_permissions_id_sygms || ''}`;
12241
+ // If this exception wasn't processed above, check if it should be deleted
12242
+ if (!processedExceptionKeys.has(exceptionKey)) {
12243
+ // Find the corresponding menu and permission to check if it matches role
12244
+ const menuRights = this.menuRightsMap()[mappingIndex.toString()] || [];
12245
+ const menu = menuRights.find((m) => m._id === existingException.syusrex_menu_id_syme);
12246
+ if (menu && menu._permissionValues) {
12247
+ const permissionId = existingException.syusrex_role_permissions_id_sygms?.toString() || '';
12248
+ const permissionData = menu._permissionValues[permissionId];
12249
+ if (permissionData && permissionData.modified === permissionData.actual) {
12250
+ // Permission matches role, but exception exists - mark for deletion
12251
+ const exceptionToDelete = {
12252
+ _id: existingException._id,
12253
+ syusrex_user_id_user: this.userId() || '',
12254
+ syusrex_user_entity_mapping_id_syenm: mapping._id || '',
12255
+ syusrex_role_id_syusrol: mapping.syenm_role_id_syusrol?._id || '',
12256
+ syusrex_role_permissions_id_sygms: permissionId,
12257
+ syusrex_menu_id_syme: menu._id || '',
12258
+ syusrex_isactive: true,
12259
+ syusrex_status: false,
12260
+ isDelete: true
12261
+ };
12262
+ exceptions.push(exceptionToDelete);
12263
+ console.log(`🗑️ Exception marked for deletion (orphaned/not in menu rights): ${existingException._id}`);
12264
+ }
12265
+ }
12266
+ }
12267
+ }
12268
+ });
12231
12269
  });
12232
12270
  console.log(`🎭 Total exceptions to process: ${exceptions.length}`, exceptions);
12233
12271
  return exceptions;