forest_admin_agent 1.11.3 → 1.11.4
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 880be64494226c28b53e647394e4ebab643eb4194256c22a4ee344bfe1805f2a
|
4
|
+
data.tar.gz: fd62a8c9511edf02d5dda971a7db8d5645c7ed428bc550c3a5f4c3d54a8254d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 448718e9e014c4a84d8554c90224437bcba502231bb5583a38a7ff30d5518005e7799765f6091a9cfe0451551b93f14efc0aee449f194a693ed4a3c48632c306
|
7
|
+
data.tar.gz: c5de0220f60301249a2f8c4fff27a4154f2e1df49fbcc39ac369bce6f4633ad47fe32c314ca84b56a4406e057b323180def3242f42c3441ee4f68cc6ef6e4091
|
@@ -37,7 +37,7 @@ module ForestAdminAgent
|
|
37
37
|
|
38
38
|
def can_approve?
|
39
39
|
if smart_action[:userApprovalEnabled].include?(role_id) &&
|
40
|
-
(condition_by_role_id(smart_action[:userApprovalConditions]).
|
40
|
+
(condition_by_role_id(smart_action[:userApprovalConditions]).nil? || match_conditions(:userApprovalConditions)) &&
|
41
41
|
(attributes[:signed_approval_request][:data][:attributes][:requester_id] != caller.id ||
|
42
42
|
smart_action[:selfApprovalEnabled].include?(role_id))
|
43
43
|
return true
|
@@ -48,17 +48,17 @@ module ForestAdminAgent
|
|
48
48
|
|
49
49
|
def can_trigger?
|
50
50
|
if smart_action[:triggerEnabled].include?(role_id) && !smart_action[:approvalRequired].include?(role_id)
|
51
|
-
if condition_by_role_id(smart_action[:triggerConditions]).
|
51
|
+
if condition_by_role_id(smart_action[:triggerConditions]).nil? || match_conditions(:triggerConditions)
|
52
52
|
return true
|
53
53
|
end
|
54
54
|
elsif smart_action[:approvalRequired].include?(role_id) && smart_action[:triggerEnabled].include?(role_id)
|
55
|
-
if condition_by_role_id(smart_action[:approvalRequiredConditions]).
|
55
|
+
if condition_by_role_id(smart_action[:approvalRequiredConditions]).nil? || match_conditions(:approvalRequiredConditions)
|
56
56
|
raise RequireApproval.new(
|
57
57
|
'This action requires to be approved.',
|
58
58
|
REQUIRE_APPROVAL_ERROR,
|
59
59
|
smart_action[:userApprovalEnabled]
|
60
60
|
)
|
61
|
-
elsif condition_by_role_id(smart_action[:triggerConditions]).
|
61
|
+
elsif condition_by_role_id(smart_action[:triggerConditions]).nil? || match_conditions(:triggerConditions)
|
62
62
|
return true
|
63
63
|
end
|
64
64
|
end
|
@@ -67,7 +67,21 @@ module ForestAdminAgent
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def match_conditions(condition_name)
|
70
|
-
|
70
|
+
pks = Schema.primary_keys(collection)
|
71
|
+
|
72
|
+
if pks.nil? || pks.empty?
|
73
|
+
ForestAdminAgent::Facades::Container.logger.log(
|
74
|
+
'Error',
|
75
|
+
"Missing primary keys for action with conditional permissions - Collection: #{collection.name}, " \
|
76
|
+
"Action: #{attributes[:smart_action_id]}"
|
77
|
+
)
|
78
|
+
|
79
|
+
raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
|
80
|
+
"Collection '#{collection.name}' has no primary keys. " \
|
81
|
+
'Actions with conditional permissions require a primary key to identify records.'
|
82
|
+
end
|
83
|
+
|
84
|
+
pk = pks[0]
|
71
85
|
condition_filter = if attributes[:all_records]
|
72
86
|
Nodes::ConditionTreeLeaf.new(pk, 'NOT_EQUAL', attributes[:all_records_ids_excluded])
|
73
87
|
else
|
@@ -86,7 +100,28 @@ module ForestAdminAgent
|
|
86
100
|
|
87
101
|
rows = collection.aggregate(caller, conditional_filter, Aggregation.new(operation: 'Count'))
|
88
102
|
(rows.empty? ? 0 : rows[0]['value']) == attributes[:ids].count
|
89
|
-
rescue
|
103
|
+
rescue ForestAdminDatasourceToolkit::Exceptions::ForestException => e
|
104
|
+
# Let primary key validation errors propagate - these are actionable schema issues
|
105
|
+
# Wrap other ForestExceptions (like invalid operators) in ConflictError
|
106
|
+
raise if e.message.include?('has no primary keys')
|
107
|
+
|
108
|
+
raise ConflictError.new(
|
109
|
+
'The conditions to trigger this action cannot be verified. Please contact an administrator.',
|
110
|
+
INVALID_ACTION_CONDITION_ERROR
|
111
|
+
)
|
112
|
+
rescue ArgumentError, TypeError => e
|
113
|
+
# Catch specific errors from condition parsing/validation
|
114
|
+
raise ConflictError.new(
|
115
|
+
"Invalid action condition: #{e.message}. Please contact an administrator.",
|
116
|
+
INVALID_ACTION_CONDITION_ERROR
|
117
|
+
)
|
118
|
+
rescue StandardError => e
|
119
|
+
# Catch unexpected errors and log for debugging
|
120
|
+
ForestAdminAgent::Facades::Container.logger.log(
|
121
|
+
'Error',
|
122
|
+
"Unexpected error in match_conditions: #{e.class} - #{e.message}"
|
123
|
+
)
|
124
|
+
|
90
125
|
raise ConflictError.new(
|
91
126
|
'The conditions to trigger this action cannot be verified. Please contact an administrator.',
|
92
127
|
INVALID_ACTION_CONDITION_ERROR
|