prevent update of any object without providing the correct/current
version as part of the XML. This affects update-only at this time: DELETE doesn't work the same way because we don't provide the data as part of a DELETE
This commit is contained in:
parent
6aa9ec599f
commit
618908319c
3 changed files with 13 additions and 0 deletions
|
@ -49,6 +49,10 @@ class NodeController < ApplicationController
|
|||
begin
|
||||
node = Node.find(params[:id])
|
||||
new_node = Node.from_xml(request.raw_post)
|
||||
if new_node.version != node.version
|
||||
render :text => "Version mismatch: Provided " + new_node.version.to_s + ", server had: " + node.version.to_s, :status => :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
if new_node and new_node.id == node.id
|
||||
node.update_from(new_node, @user)
|
||||
|
|
|
@ -49,6 +49,10 @@ class RelationController < ApplicationController
|
|||
begin
|
||||
relation = Relation.find(params[:id])
|
||||
new_relation = Relation.from_xml(request.raw_post)
|
||||
if new_relation.version != relation.version
|
||||
render :text => "Version mismatch: Provided " + new_relation.version.to_s + ", server had: " + relation.version.to_s, :status => :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
if new_relation and new_relation.id == relation.id
|
||||
relation.update_from new_relation, user
|
||||
|
|
|
@ -49,6 +49,11 @@ class WayController < ApplicationController
|
|||
begin
|
||||
way = Way.find(params[:id])
|
||||
new_way = Way.from_xml(request.raw_post)
|
||||
if new_way.version != way.version
|
||||
render :text => "Version mismatch: Provided " + new_way.version.to_s + ", server had: " + way.version.to_s, :status => :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if new_way and new_way.id == way.id
|
||||
way.update_from(new_way, @user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue