@@ -122,6 +122,10 @@ public struct ParseCLP: Codable, Equatable {
122
122
123
123
// MARK: Default Implementation
124
124
extension ParseCLP {
125
+ static func getUserFieldAccess( _ field: String ) -> String {
126
+ " userField: \( field) "
127
+ }
128
+
125
129
func hasAccess( _ keyPath: KeyPath < Self , [ String : AnyCodable ] ? > ,
126
130
for entity: String ) -> Bool {
127
131
self [ keyPath: keyPath] ? [ entity] ? . value as? Bool ?? false
@@ -801,6 +805,17 @@ public extension ParseCLP {
801
805
getProtectedFields ( Access . requiresAuthentication. rawValue)
802
806
}
803
807
808
+ /**
809
+ Get the protected fields either a field of `ParseUser` type or
810
+ an array of `ParseUser`'s in a Parse class cannot access.
811
+ - parameter field: A field in a Parse class that is either of `ParseUser` type or
812
+ an array of `ParseUser`'s.
813
+ - returns: The set protected fields that cannot be accessed.
814
+ */
815
+ func getProtectedFieldsUser( _ field: String ) -> Set < String > {
816
+ getProtectedFields ( Self . getUserFieldAccess ( field) )
817
+ }
818
+
804
819
/**
805
820
Get the protected fields the given `ParseUser` objectId cannot access.
806
821
- parameter objectId: The `ParseUser` objectId access to check.
@@ -862,10 +877,25 @@ public extension ParseCLP {
862
877
setProtected ( fields, on: \. protectedFields, for: Access . requiresAuthentication. rawValue)
863
878
}
864
879
880
+ /**
881
+ Set whether the given field that is either of `ParseUser` type or an array of `ParseUser`'s
882
+ should not have access to specific fields of a Parse class.
883
+ - parameter fields: The set of fields that should be protected from access.
884
+ - parameter userField: A field in a Parse class that is either of `ParseUser` type or
885
+ an array of `ParseUser`'s to restrict access to.
886
+ - returns: A mutated instance of `ParseCLP` for easy chaining.
887
+ - throws: An error of type `ParseError`.
888
+ */
889
+ func setProtectedFields( _ fields: Set < String > , userField: String ) -> Self {
890
+ setProtected ( fields,
891
+ on: \. protectedFields,
892
+ for: Self . getUserFieldAccess ( userField) )
893
+ }
894
+
865
895
/**
866
896
Set whether the given `ParseUser` objectId should not have access to specific fields of a Parse class.
867
- - parameter objectId: The `ParseUser` objectId to restrict access to.
868
897
- parameter fields: The set of fields that should be protected from access.
898
+ - parameter objectId: The `ParseUser` objectId to restrict access to.
869
899
- returns: A mutated instance of `ParseCLP` for easy chaining.
870
900
- throws: An error of type `ParseError`.
871
901
*/
@@ -930,6 +960,20 @@ public extension ParseCLP {
930
960
addProtected ( fields, on: \. protectedFields, for: Access . requiresAuthentication. rawValue)
931
961
}
932
962
963
+ /**
964
+ Add to the set of specific fields the given field that is either of `ParseUser` type or an array of `ParseUser`'s
965
+ should not have access to on a Parse class.
966
+ - parameter fields: The set of fields that should be protected from access.
967
+ - parameter userField: A field in a Parse class that is either of `ParseUser` type or
968
+ an array of `ParseUser`'s to restrict access to.
969
+ - returns: A mutated instance of `ParseCLP` for easy chaining.
970
+ - throws: An error of type `ParseError`.
971
+ - note: This method adds on to the current set of `fields` in the CLP.
972
+ */
973
+ func addProtectedFieldsUser( _ fields: Set < String > , userField: String ) -> Self {
974
+ addProtected ( fields, on: \. protectedFields, for: Self . getUserFieldAccess ( userField) )
975
+ }
976
+
933
977
/**
934
978
Add to the set of specific fields the given `ParseUser` objectId should not have access to on a Parse class.
935
979
- parameter fields: The set of fields that should be protected from access.
@@ -1003,6 +1047,20 @@ public extension ParseCLP {
1003
1047
removeProtected ( fields, on: \. protectedFields, for: Access . requiresAuthentication. rawValue)
1004
1048
}
1005
1049
1050
+ /**
1051
+ Remove fields from the set of specific fields the given field that is either of `ParseUser` type
1052
+ or an array of `ParseUser`'s should not have access to on a Parse class.
1053
+ - parameter fields: The set of fields that should be removed from protected access.
1054
+ - parameter userField: A field in a Parse class that is either of `ParseUser` type or
1055
+ an array of `ParseUser`'s to restrict access to.
1056
+ - returns: A mutated instance of `ParseCLP` for easy chaining.
1057
+ - throws: An error of type `ParseError`.
1058
+ - note: This method removes from the current set of `fields` in the CLP.
1059
+ */
1060
+ func removeProtectedFieldsUser( _ fields: Set < String > , userField: String ) -> Self {
1061
+ removeProtected ( fields, on: \. protectedFields, for: Self . getUserFieldAccess ( userField) )
1062
+ }
1063
+
1006
1064
/**
1007
1065
Remove fields from the set of specific fields the given `ParseUser` objectId
1008
1066
should not have access to on a Parse class.
0 commit comments