summaryrefslogtreecommitdiff
path: root/users/app/controllers/controller_extension/authentication.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-07-02 23:11:23 -0700
committerelijah <elijah@riseup.net>2013-07-02 23:11:23 -0700
commitfbe23fc59814f0b27dbc1073c34f03a6d22cab99 (patch)
tree82c1120f84f33c619257b8c0a01d6906e752b79d /users/app/controllers/controller_extension/authentication.rb
parent3dbf13f3c53a741341897aa2af36d6ef8dcead2c (diff)
add js to report all errors to the user, not just ones related to field validation.
Diffstat (limited to 'users/app/controllers/controller_extension/authentication.rb')
-rw-r--r--users/app/controllers/controller_extension/authentication.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/users/app/controllers/controller_extension/authentication.rb b/users/app/controllers/controller_extension/authentication.rb
index f0a6564..72df7a7 100644
--- a/users/app/controllers/controller_extension/authentication.rb
+++ b/users/app/controllers/controller_extension/authentication.rb
@@ -38,9 +38,18 @@ module ControllerExtension::Authentication
end
def access_denied
- # TODO: should we redirect to the root_url in either case, and have the root_url include the login screen (and also ability to create unauthenticated tickets) when no user is logged in?
- redirect_to login_url, :alert => "Not authorized" if !logged_in?
- redirect_to root_url, :alert => "Not authorized" if logged_in?
+ respond_to do |format|
+ format.html do
+ if logged_in?
+ redirect_to root_url, :alert => t(:not_authorized)
+ else
+ redirect_to login_url, :alert => t(:not_authorized_login)
+ end
+ end
+ format.json do
+ render :json => {'error' => t(:not_authorized)}, status: :unprocessable_entity
+ end
+ end
end
def admin?