mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-25 12:20:32 -04:00
Fixed #356.
This commit is contained in:
parent
ba3c4af536
commit
c94a73e066
1 changed files with 11 additions and 4 deletions
|
@ -252,9 +252,13 @@ module.exports = class Handler
|
|||
return @sendDatabaseError(res, err) if err
|
||||
return @sendNotFoundError(res) unless parentDocument?
|
||||
return @sendUnauthorizedError(res) unless @hasAccessToDocument(req, parentDocument)
|
||||
editableProperties = @getEditableProperties req, parentDocument
|
||||
updatedObject = parentDocument.toObject()
|
||||
changes = _.pick req.body, @getEditableProperties(req, parentDocument)
|
||||
_.extend updatedObject, changes
|
||||
for prop in editableProperties
|
||||
if (val = req.body[prop])?
|
||||
updatedObject[prop] = val
|
||||
else if updatedObject[prop]?
|
||||
delete updatedObject[prop]
|
||||
delete updatedObject._id
|
||||
major = req.body.version?.major
|
||||
|
||||
|
@ -304,8 +308,11 @@ module.exports = class Handler
|
|||
done(err, document)
|
||||
|
||||
saveChangesToDocument: (req, document, done) ->
|
||||
for prop in @getEditableProperties(req, document)
|
||||
document.set(prop, req.body[prop]) if req.body[prop]?
|
||||
for prop in @getEditableProperties req, document
|
||||
if (val = req.body[prop])?
|
||||
document.set prop, val
|
||||
else if document.get(prop)? and req.method isnt 'PATCH'
|
||||
document.unset prop
|
||||
obj = document.toObject()
|
||||
|
||||
# Hack to get saving of Users to work. Probably should replace these props with strings
|
||||
|
|
Loading…
Add table
Reference in a new issue