X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/a1b179fa384d689e6cb78c2b8d863621e7bff152..414c4b2c36bc78ece037e30bf8139b129abcd280:/app/controllers/traces_controller.rb diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb index c77d884b3..253bc4160 100644 --- a/app/controllers/traces_controller.rb +++ b/app/controllers/traces_controller.rb @@ -4,14 +4,15 @@ class TracesController < ApplicationController skip_before_action :verify_authenticity_token, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data] before_action :authorize_web before_action :set_locale - before_action :require_user, :only => [:mine, :new, :create, :edit, :delete] before_action :authorize, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data] + before_action :api_deny_access_handler, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data] + + authorize_resource + before_action :check_database_readable, :except => [:api_read, :api_data] before_action :check_database_writable, :only => [:new, :create, :edit, :delete, :api_create, :api_update, :api_delete] before_action :check_api_readable, :only => [:api_read, :api_data] before_action :check_api_writable, :only => [:api_create, :api_update, :api_delete] - before_action :require_allow_read_gpx, :only => [:api_read, :api_data] - before_action :require_allow_write_gpx, :only => [:api_create, :api_update, :api_delete] before_action :offline_warning, :only => [:mine, :show] before_action :offline_redirect, :only => [:new, :create, :edit, :delete, :data, :api_create, :api_delete, :api_data] around_action :api_call_handle_error, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data] @@ -92,8 +93,8 @@ class TracesController < ApplicationController def show @trace = Trace.find(params[:id]) - if @trace && @trace.visible? && - (@trace.public? || @trace.user == current_user) + if @trace&.visible? && + (@trace&.public? || @trace&.user == current_user) @title = t ".title", :name => @trace.name else flash[:error] = t ".trace_not_found" @@ -318,7 +319,7 @@ class TracesController < ApplicationController visibility = params[:visibility] if visibility.nil? - visibility = if params[:public] && params[:public].to_i.nonzero? + visibility = if params[:public]&.to_i&.nonzero? "public" else "private"