Skip to content

Commit

Permalink
Issue #670: Redirect users when trying to view an essence or item and…
Browse files Browse the repository at this point in the history
… they lack authorisation, but can view the item or collection
  • Loading branch information
agrimmtt committed Jul 23, 2018
1 parent 463d276 commit cc11351
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ def make_action_mailer_use_request_host
render nothing: true, :status => 403
when request.format.symbol == :json
render nothing: true, :status => 401
# A user is trying to view an item, lacks authorization, but is able to view the collection
when exception.message == "Not authorized to show item." && params[:controller] == "items" && params[:action] == "show"
redirect_to collection_path(params[:collection_id]), :alert => exception.message
# A user is trying to view an essence, lacks authorization, but is able to view the item
when exception.message == "Not authorized to show essence." && params[:controller] == "essences" && params[:action] == "show"
redirect_to collection_item_path(params[:collection_id], params[:item_id]), :alert => exception.message
# A user is trying to view an essence, lacks authorization, but is able to view the collection
when exception.message == "Not authorized to show item." && params[:controller] == "essences" && params[:action] == "show"
redirect_to collection_path(params[:collection_id]), :alert => exception.message
when current_user
redirect_to root_url, :alert => exception.message
else
Expand Down

0 comments on commit cc11351

Please sign in to comment.