summaryrefslogtreecommitdiff
path: root/app/controllers/controller_extension/errors.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-03-28 15:52:21 -0700
committerelijah <elijah@riseup.net>2016-03-28 16:03:54 -0700
commit67b5aa4198e0f6ab2cd29767aedcb4bf5b5dc4d9 (patch)
treecfea468d3d70363298490cc1ad7b8085688530b7 /app/controllers/controller_extension/errors.rb
parentc63791c7ffacb7c6cfc685e2654ffe66f0a6b185 (diff)
api tokens - clarify terms: "monitors" are admins that authenticated via api token, "tmp" users are users that exist only in tmp db, "test" users are either tmp users or users named "test_user_x"
Diffstat (limited to 'app/controllers/controller_extension/errors.rb')
-rw-r--r--app/controllers/controller_extension/errors.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/controllers/controller_extension/errors.rb b/app/controllers/controller_extension/errors.rb
index 8f8edde..2b68955 100644
--- a/app/controllers/controller_extension/errors.rb
+++ b/app/controllers/controller_extension/errors.rb
@@ -4,21 +4,22 @@ module ControllerExtension::Errors
protected
def access_denied
- respond_to_error :not_authorized, :forbidden, home_url
+ render_error :not_authorized, :forbidden, home_url
end
def login_required
# Warden will intercept the 401 response and call
# SessionController#unauthenticated instead.
- respond_to_error :not_authorized_login, :unauthorized, login_url
+ render_error :not_authorized_login, :unauthorized, login_url
end
- def not_found
- respond_to_error :not_found, :not_found, home_url
+ def not_found(msg=nil, url=nil)
+ render_error(msg || :not_found, :not_found, url || home_url)
end
+ private
- def respond_to_error(message, status=nil, redirect=nil)
+ def render_error(message, status=nil, redirect=nil)
error = message
message = t(message) if message.is_a?(Symbol)
respond_to do |format|