summaryrefslogtreecommitdiff
path: root/users/app/controllers/controller_extension
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-07-06 07:51:54 -0700
committerazul <azul@riseup.net>2013-07-06 07:51:54 -0700
commita18efa42ddc1cf8692d55f76ca3e92792913f40d (patch)
tree00527737a38bdafcd2e175bb6caf5e30b3360de1 /users/app/controllers/controller_extension
parentd03e82b4df5075f796f56fb9568992b0ba0d7c07 (diff)
parentdc98ad8c6445182d60b3f1909e0260ace6fbfca5 (diff)
Merge pull request #55 from elijh/feature/new-ui
Feature/new ui
Diffstat (limited to 'users/app/controllers/controller_extension')
-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?