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

Properly check sessionToken when decoding ParseObjects from LiveQuery. #17

Merged
merged 1 commit into from
Mar 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Sources/ParseLiveQuery/Internal/ClientPrivate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ private func parseObject<T: PFObject>(objectDictionary: [String:AnyObject]) thro

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

// Map of strings to closures to determine if the key is valid. Allows for more advanced checking of
// classnames and such.
let invalidKeys: [String:Void->Bool] = [
"objectId": { true },
"parseClassName": { true },
"sessionToken": { parseClassName == "_User" }
]

objectDictionary.filter { key, _ in
key != "parseClassName" && key != "objectId"
}.forEach { key, value in
parseObject[key] = value
return !(invalidKeys[key].map { $0() } ?? false)
}.forEach { key, value in
parseObject[key] = value
}
return parseObject
}
Expand Down