You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance ACL permission methods with array and pointer support
ACL permission methods (`readable_by?`, `writeable_by?`, `owner?`) now accept arrays for OR logic and support Parse::Pointer to User objects with automatic role expansion. Permission checks for users and pointers automatically include associated roles, improving flexibility for multi-user/role permission checks. Also fixes pointer constraint conversion in `group_by_date` for MongoDB aggregation, resolving empty result issues. Adds comprehensive tests for new ACL behaviors.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,16 @@
1
1
## Parse-Stack Changelog
2
2
3
+
### 2.0.7
4
+
5
+
-**NEW**: `readable_by?`, `writeable_by?`, and `owner?` ACL methods now accept arrays for OR logic
6
+
-**NEW**: ACL permission methods now support Parse::Pointer to User objects with automatic role expansion
7
+
-**ENHANCED**: ACL permission checking methods support checking if ANY user/role in an array has the specified permission
8
+
-**ENHANCED**: When passed a Parse::User object or Parse::Pointer to User, automatically queries and checks the user's roles
9
+
-**ENHANCED**: Array support works with user IDs and role names (strings)
10
+
-**IMPROVED**: Better flexibility for checking permissions across multiple users and roles simultaneously
11
+
-**IMPROVED**: Parse::Pointer to User queries roles without needing to fetch the full user object
12
+
-**FIXED**: `group_by_date` now properly converts Parse pointer constraints to MongoDB aggregation format, fixing empty result issues when filtering by Parse object references
13
+
3
14
### 2.0.6
4
15
5
16
-**NEW**: Added `:minute` and `:second` interval support to `group_by_date` for minute-level and second-level time grouping
Copy file name to clipboardExpand all lines: lib/parse/model/acl.rb
+224-9Lines changed: 224 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -436,19 +436,161 @@ def writeable_by
436
436
end
437
437
alias_method:writable_by,:writeable_by
438
438
439
-
# Checks if a specific user or role has read access to this object.
440
-
# @param user_or_role [String, Parse::User, Parse::Role] the user ID, role name, user object, or role object
441
-
# @return [Boolean] true if the user/role has read access
439
+
# Checks if a specific user or role (or any in an array) has read access to this object.
440
+
# When passed an array of strings, returns true if ANY of the users/roles have read access (OR logic).
441
+
# When passed a Parse::User object or pointer, automatically fetches and checks the user's roles as well.
442
+
# @param user_or_role [String, Parse::User, Parse::Pointer, Array<String>] the user ID, role name, user object, user pointer, or array of user IDs/role names
443
+
# @return [Boolean] true if the user/role (or any in the array) has read access
444
+
# @example
445
+
# acl.readable_by?("user123") # Check single user ID
446
+
# acl.readable_by?("Admin") # Check single role name
447
+
# acl.readable_by?(user_object) # Check user + their roles
448
+
# acl.readable_by?(user_pointer) # Check user pointer + their roles
# Checks if a specific user or role has write access to this object.
449
-
# @param user_or_role [String, Parse::User, Parse::Role] the user ID, role name, user object, or role object
450
-
# @return [Boolean] true if the user/role has write access
519
+
# Checks if a specific user or role (or any in an array) has write access to this object.
520
+
# When passed an array of strings, returns true if ANY of the users/roles have write access (OR logic).
521
+
# When passed a Parse::User object or pointer, automatically fetches and checks the user's roles as well.
522
+
# @param user_or_role [String, Parse::User, Parse::Pointer, Array<String>] the user ID, role name, user object, user pointer, or array of user IDs/role names
523
+
# @return [Boolean] true if the user/role (or any in the array) has write access
524
+
# @example
525
+
# acl.writeable_by?("user123") # Check single user ID
526
+
# acl.writeable_by?("Admin") # Check single role name
527
+
# acl.writeable_by?(user_object) # Check user + their roles
528
+
# acl.writeable_by?(user_pointer) # Check user pointer + their roles
# Checks if a specific user or role has both read and write access to this object.
503
-
# @param user_or_role [String, Parse::User, Parse::Role] the user ID, role name, user object, or role object
504
-
# @return [Boolean] true if the user/role has both read and write access
644
+
# Checks if a specific user or role (or any in an array) has both read and write access to this object.
645
+
# When passed an array of strings, returns true if ANY of the users/roles have both read and write access (OR logic).
646
+
# When passed a Parse::User object or pointer, automatically fetches and checks the user's roles as well.
647
+
# @param user_or_role [String, Parse::User, Parse::Pointer, Array<String>] the user ID, role name, user object, user pointer, or array of user IDs/role names
648
+
# @return [Boolean] true if the user/role (or any in the array) has both read and write access
649
+
# @example
650
+
# acl.owner?("user123") # Check single user ID
651
+
# acl.owner?("Admin") # Check single role name
652
+
# acl.owner?(user_object) # Check user + their roles
653
+
# acl.owner?(user_pointer) # Check user pointer + their roles
0 commit comments