Skip to content

Commit 797b8f5

Browse files
committed
Fix code visibility
1 parent f4720f8 commit 797b8f5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/controllers/submissions_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class SubmissionsController < ApplicationController
55
before_action :set_submission, only: [:rejudge, :show, :show_old, :download_raw, :edit, :update, :destroy]
66
before_action :set_problem_by_param, only: [:new, :create, :index]
77
before_action :check_problem_visibility
8+
before_action :check_code_visibility, only: [:download_raw]
89
before_action :check_contest_status, only: [:new, :create]
910
before_action :set_submissions, only: [:index]
1011
before_action :redirect_contest, only: [:show, :show_old, :download_raw, :edit]
@@ -252,6 +253,13 @@ def check_problem_visibility
252253
raise_not_found if @problem.visible_contest? && !@contest&.is_started?
253254
end
254255

256+
def check_code_visibility
257+
unless effective_admin? || current_user&.id == @submission.user_id
258+
redirect_to problem_path(@problem), alert: 'Insufficient User Permissions.'
259+
return
260+
end
261+
end
262+
255263
def normalize_code
256264
if params[:submission][:code_file]
257265
code = params[:submission][:code_file].read

config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Bundler.require(*Rails.groups)
88

99
module Tioj
10-
VERSION = '3.0.3'
10+
VERSION = '3.0.4'
1111
class Application < Rails::Application
1212
# Initialize configuration defaults for originally generated Rails version.
1313
config.load_defaults 7.0

0 commit comments

Comments
 (0)