]> git.openstreetmap.org Git - rails.git/commitdiff
Rework the default denied access handler to give different responses to tokens, logge...
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 24 Oct 2018 07:39:02 +0000 (09:39 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 24 Oct 2018 07:39:02 +0000 (09:39 +0200)
app/controllers/application_controller.rb
config/locales/en.yml

index 0d43393fd4ff6334c0ed0c929c773d5565dd0333..690bdf5ca5140dad6448e86af7e6d02732ce7c35 100644 (file)
@@ -477,11 +477,16 @@ class ApplicationController < ActionController::Base
   end
 
   def deny_access(_exception)
-    if current_user
+    if current_token
       set_locale
       report_error t("oauth.permissions.missing"), :forbidden
+    elsif current_user
+      set_locale
+      report_error t("application.permission_denied"), :forbidden
+    elsif request.get?
+      redirect_to :controller => "users", :action => "login", :referer => request.fullpath
     else
-      require_user
+      head :forbidden
     end
   end
 
index 6e126e27e3fd8cfb793811961dbf2b3ef2c8ec19..6942c1720e58b996f330da83785719a5e951ddd4 100644 (file)
@@ -1793,6 +1793,7 @@ en:
         other: "GPX file with %{count} points from %{user}"
       description_without_count: "GPX file from %{user}"
   application:
+    permission_denied: You do not have permission to access that action
     require_cookies:
       cookies_needed: "You appear to have cookies disabled - please enable cookies in your browser before continuing."
     require_admin: