summaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index bf05db034..f031ac292 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -314,6 +314,19 @@ class ApplicationController < ActionController::Base
format.json { head @status }
end
end
+
+ # Filter for actions that provide an API response
+ # but have no HTML representation for non admin users
+ def require_admin_or_api_request
+ return true if api_request?
+ if User.current.admin?
+ true
+ elsif User.current.logged?
+ render_error(:status => 406)
+ else
+ deny_access
+ end
+ end
# Picks which layout to use based on the request
#