Skip to content

Commit

Permalink
add namespaces check in synchronization configuration feature
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed Aug 3, 2024
1 parent 8f716ac commit 621c151
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public List<ItemDiffs> diff(@RequestBody NamespaceSyncModel model) {
@PutMapping(value = "/apps/{appId}/namespaces/{namespaceName}/items", consumes = {"application/json"})
public ResponseEntity<Void> update(@PathVariable String appId, @PathVariable String namespaceName,
@RequestBody NamespaceSyncModel model) {
checkModel(!model.isInvalid());
checkModel(!model.isInvalid() && model.syncToNamespacesValid(appId, namespaceName));
boolean hasPermission = permissionValidator.hasModifyNamespacePermission(appId, namespaceName);
Env envNoPermission = null;
// if uses has ModifyNamespace permission then he has permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ public boolean isInvalid() {
return false;
}

public boolean syncToNamespacesValid(String appId, String namespaceName) {
for (NamespaceIdentifier namespaceIdentifier : syncToNamespaces) {
if (appId.equals(namespaceIdentifier.getAppId()) && namespaceName.equals(
namespaceIdentifier.getNamespaceName())) {
continue;
}
return false;
}
return true;
}

public List<NamespaceIdentifier> getSyncToNamespaces() {
return syncToNamespaces;
}
Expand Down

0 comments on commit 621c151

Please sign in to comment.