Skip to content

Commit

Permalink
Only ensure a CbrainFileList read access at task launch, resolves ace…
Browse files Browse the repository at this point in the history
  • Loading branch information
MontrealSergiy committed Jul 30, 2024
1 parent 03a77d4 commit 3987f3d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions BrainPortal/app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,19 @@ def new #:nodoc:

# Filter list of files as provided by the get request
file_ids = params[:file_ids] || []
cb_file_ids = CbrainFileList.where(:id => file_ids).pluck(:id)
other_file_ids = file_ids.map(&:to_i) - cb_file_ids
if @tool_config.try(:inputs_readonly) || @task.class.properties[:readonly_input_files]
access = :read
else
access = :write
end
@files = Userfile.find_accessible_by_user(file_ids, current_user, :access_requested => access) rescue []
if @files.count == 0
flash[:error] = "You must select at least one file to which you have write access."
cb_files = Userfile.find_accessible_by_user(cb_file_ids, current_user, :access_requested => :read) rescue []
other_files = Userfile.find_accessible_by_user(other_file_ids, current_user, :access_requested => access) rescue []
@files = cb_files + other_files
if @files.count != file_ids.count
flash[:error] = "Select files to which you have #{access} access."
flash[:error] = "You must select at least one file." if @files.count == 0
redirect_to :controller => :userfiles, :action => :index
return
end
Expand Down

0 comments on commit 3987f3d

Please sign in to comment.