diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index 8956919e..9d85ce69 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -76,9 +76,10 @@ class ContextController < ApplicationController # def order @params["list-contexts"].each_with_index do |id, position| - Context.update(id, :position => position + 1) + if check_user_matches_context_user(id) + Context.update(id, :position => position + 1) + end end - render_text "" end protected @@ -101,7 +102,18 @@ class ContextController < ApplicationController end end - + def check_user_matches_context_user(id) + @user = @session['user'] + @context = Context.find_by_id_and_user_id(id, @user.id) + if @user == @context.user + return @context + else + @context = nil + flash["warning"] = "Project and session user mis-match: #{@context.user_id} and #{@session['user'].id}!" + render_text "" + end + end + def init @user = @session['user'] @projects = @user.projects.collect { |x| x.done? ? nil:x }.compact diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index 8e5f9174..8294f193 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -73,9 +73,10 @@ class ProjectController < ApplicationController # def order @params["list-projects"].each_with_index do |id, position| - Project.update(id, :position => position + 1) + if check_user_matches_project_user(id) + Project.update(id, :position => position + 1) + end end - render_text "" end protected @@ -98,6 +99,18 @@ class ProjectController < ApplicationController end end + def check_user_matches_project_user(id) + @user = @session['user'] + @project = Project.find_by_id_and_user_id(id, @user.id) + if @user == @project.user + return @project + else + @project = nil + flash["warning"] = "Project and session user mis-match: #{@project.user_id} and #{@session['user'].id}!" + render_text "" + end + end + def init @user = @session['user'] @projects = @user.projects diff --git a/tracks/app/views/context/_context_listing.rhtml b/tracks/app/views/context/_context_listing.rhtml index 2ddcbeab..af17241b 100644 --- a/tracks/app/views/context/_context_listing.rhtml +++ b/tracks/app/views/context/_context_listing.rhtml @@ -1,7 +1,6 @@ <% context = context_listing %> -
+
-
DRAG @@ -27,7 +26,6 @@
-