Raise a RoutingError for unknown foodcoop in multi_coop_installs
This gives the correct error code for request to files in the root folder (e.g. /apple-touch-icon.png), which do not exist.
This commit is contained in:
parent
0edc780ec7
commit
52dc7b1387
3 changed files with 23 additions and 15 deletions
|
|
@ -177,19 +177,16 @@ class ApplicationController < ActionController::Base
|
|||
# It uses the subdomain to select the appropriate section in the config files
|
||||
# Use this method as a before filter (first filter!) in ApplicationController
|
||||
def select_foodcoop
|
||||
if FoodsoftConfig[:multi_coop_install]
|
||||
if params[:foodcoop].present?
|
||||
begin
|
||||
# Set Config and database connection
|
||||
FoodsoftConfig.select_foodcoop params[:foodcoop]
|
||||
rescue => error
|
||||
FoodsoftConfig.select_default_foodcoop
|
||||
redirect_to root_url, alert: error.message
|
||||
end
|
||||
else
|
||||
FoodsoftConfig.select_default_foodcoop
|
||||
redirect_to root_url
|
||||
end
|
||||
return unless FoodsoftConfig[:multi_coop_install]
|
||||
|
||||
foodcoop = params[:foodcoop]
|
||||
if foodcoop.blank?
|
||||
FoodsoftConfig.select_default_foodcoop
|
||||
redirect_to root_url
|
||||
elsif FoodsoftConfig.allowed_foodcoop? foodcoop
|
||||
FoodsoftConfig.select_foodcoop foodcoop
|
||||
else
|
||||
raise ActionController::RoutingError.new 'Foodcoop Not Found'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue