comparison app/controllers/application_controller.rb @ 1521:2354ddf5a483 redmine-2.5-integration

Fix some merge/runtime problems
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 09 Sep 2014 14:27:58 +0100
parents a1bdbf8a87d5
children
comparison
equal deleted inserted replaced
1520:a1bdbf8a87d5 1521:2354ddf5a483
375 end 375 end
376 376
377 def redirect_back_or_default(default, options={}) 377 def redirect_back_or_default(default, options={})
378 back_url = params[:back_url].to_s 378 back_url = params[:back_url].to_s
379 if back_url.present? && valid_back_url?(back_url) 379 if back_url.present? && valid_back_url?(back_url)
380 begin
381 uri = URI.parse(back_url)
382 # do not redirect user to another host or to the login or register page
383 if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
380 # soundsoftware: if back_url is the home page, 384 # soundsoftware: if back_url is the home page,
381 # change it to My Page (#125) 385 # change it to My Page (#125)
382 if (uri.path == home_path) 386 if (uri.path == home_path)
383 if (uri.path =~ /\/$/) 387 if (uri.path =~ /\/$/)
384 uri.path = uri.path + "my" 388 uri.path = uri.path + "my"
390 # switch back_url to https to ensure cookie validity (#83) 394 # switch back_url to https to ensure cookie validity (#83)
391 if (uri.scheme == "http") && (URI.parse(request.url).scheme == "https") 395 if (uri.scheme == "http") && (URI.parse(request.url).scheme == "https")
392 uri.scheme = "https" 396 uri.scheme = "https"
393 end 397 end
394 back_url = uri.to_s 398 back_url = uri.to_s
395 redirect_to(back_url) 399 redirect_to(back_url)
396 return 400 return
401 end
402 rescue URI::InvalidURIError
403 logger.warn("Could not redirect to invalid URL #{back_url}")
404 # redirect to default
405 end
397 elsif options[:referer] 406 elsif options[:referer]
398 redirect_to_referer_or default 407 redirect_to_referer_or default
399 return 408 return
400 end 409 end
401 redirect_to default 410 redirect_to default