Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit ee1a09c

Browse files
Merge pull request #17 from ParsePlatform/richardross.sessiontoken.fix
Properly check sessionToken when decoding ParseObjects from LiveQuery.
2 parents fcb1db9 + 0c0b454 commit ee1a09c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Sources/ParseLiveQuery/Internal/ClientPrivate.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ private func parseObject<T: PFObject>(objectDictionary: [String:AnyObject]) thro
2222

2323
let parseObject = T(withoutDataWithClassName: parseClassName, objectId: objectId)
2424

25+
// Map of strings to closures to determine if the key is valid. Allows for more advanced checking of
26+
// classnames and such.
27+
let invalidKeys: [String:Void->Bool] = [
28+
"objectId": { true },
29+
"parseClassName": { true },
30+
"sessionToken": { parseClassName == "_User" }
31+
]
32+
2533
objectDictionary.filter { key, _ in
26-
key != "parseClassName" && key != "objectId"
27-
}.forEach { key, value in
28-
parseObject[key] = value
34+
return !(invalidKeys[key].map { $0() } ?? false)
35+
}.forEach { key, value in
36+
parseObject[key] = value
2937
}
3038
return parseObject
3139
}

0 commit comments

Comments
 (0)