Skip to content

Commit

Permalink
Merge pull request #71 from abhasg/before_redirect
Browse files Browse the repository at this point in the history
Fixing issue #70 - Running code before redirect not working
  • Loading branch information
tobmatth committed Apr 22, 2014
2 parents 1b2e524 + df337f7 commit baa6e4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
```

Expand Down
2 changes: 1 addition & 1 deletion lib/rack/ssl-enforcer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit baa6e4d

Please sign in to comment.