]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/application_controller.rb
Simplify deny_access handling
[rails.git] / app / controllers / application_controller.rb
index 8d9ee11f94929360b0b3ca7728ed1eddfbfd8741..485c30b21a65de7016d0e9f08067ee916b46e1d4 100644 (file)
@@ -395,15 +395,7 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def deny_access(exception)
-    if @api_deny_access_handling
-      api_deny_access(exception)
-    else
-      web_deny_access(exception)
-    end
-  end
-
-  def web_deny_access(_exception)
+  def deny_access(_exception)
     if current_token
       set_locale
       report_error t("oauth.permissions.missing"), :forbidden
@@ -423,26 +415,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def api_deny_access(_exception)
-    if current_token
-      set_locale
-      report_error t("oauth.permissions.missing"), :forbidden
-    elsif current_user
-      head :forbidden
-    else
-      realm = "Web Password"
-      errormessage = "Couldn't authenticate you"
-      response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
-      render :plain => errormessage, :status => :unauthorized
-    end
-  end
-
-  attr_accessor :api_access_handling
-
-  def api_deny_access_handler
-    @api_deny_access_handling = true
-  end
-
   private
 
   # extract authorisation credentials from headers, returns user = nil if none