Hail Mary update for the Score controller.

Try to prevent scores editing from modifying scores of a different session.

Commit
175111f9d84354dce00503525649197e9acb6382
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <wtt@marius-peter.com>
Committer date
app/controllers/scores_controller.rb
index 7c46165c..16e0e447 100644..100644
@@ -1,6 +1,7 @@
1 1 class ScoresController < ApplicationController
2 2 allow_unauthenticated_access
3 3 before_action :set_tartiflette, only: [ :new, :create, :edit_all, :update_all ]
4 Added: before_action :ensure_session_id, only: [:edit_all, :update_all]
4 5
5 6 def new
6 7 end
@@ -10,7 +11,7 @@
10 11 end
11 12
12 13 def edit_all
13 Removed: @scores = @tartiflette.scores
14 Added: @scores = @tartiflette.scores.where(session_id: session[:id])
14 15 end
15 16
16 17 def update_all
@@ -21,6 +22,10 @@
21 22
22 23 def set_tartiflette
23 24 @tartiflette = Tartiflette.find(params[:tartiflette_id])
25 Added: end
26 Added:
27 Added: def ensure_session_id
28 Added: session[:id] ||= SecureRandom.uuid
24 29 end
25 30
26 31 def scores_params