From df337f72450a5b3e2964adbb32167a574230088d Mon Sep 17 00:00:00 2001 From: abhas Date: Wed, 2 Apr 2014 11:25:57 +0530 Subject: [PATCH] Fixing issue #70 - Running code before redirect not working --- README.md | 4 ++-- lib/rack/ssl-enforcer.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f97c3c..de5bd7e 100644 --- a/README.md +++ b/README.md @@ -216,9 +216,9 @@ You may want to run some code before rack-ssl-enforcer forces a redirect. This ```ruby -config.middleware.use Rack::SslEnforcer, :only => '/login', :before_redirect => Proc.new { +config.middleware.use Rack::SslEnforcer, :only => '/login', :before_redirect => Proc.new { |request| #keep flash on redirect - @request.session[:flash].keep if !@request.session.nil? && @request.session.key?('flash') && !@request.session['flash'].empty? + request.session[:flash].keep if !request.session.nil? && request.session.key?('flash') && !request.session['flash'].empty? } ``` diff --git a/lib/rack/ssl-enforcer.rb b/lib/rack/ssl-enforcer.rb index 35847e1..5aae805 100644 --- a/lib/rack/ssl-enforcer.rb +++ b/lib/rack/ssl-enforcer.rb @@ -84,7 +84,7 @@ def host_mismatch? end def call_before_redirect - @options[:before_redirect].call unless @options[:before_redirect].nil? + @options[:before_redirect].call(@request) unless @options[:before_redirect].nil? end def modify_location_and_redirect