Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds 'origin' param to default failure redirect. Closes #569

commit bcd891aec40ca66016600d418371d6df0885cce4 1 parent 98fac7b
Michael Bleigh authored
View
7 lib/omniauth/failure_endpoint.rb
@@ -27,8 +27,13 @@ def raise_out!
def redirect_to_failure
message_key = env['omniauth.error.type']
- new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
+ new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}"
Rack::Response.new(["302 Moved"], 302, 'Location' => new_path).finish
end
+
+ def origin_query_param
+ return "" unless env['omniauth.origin']
+ "&origin=#{CGI.escape(env['omniauth.origin'])}"
+ end
end
end
View
6 spec/omniauth/failure_endpoint_spec.rb
@@ -41,5 +41,11 @@
status, head, body = *subject.call(env)
head["Location"].should == '/boo/failure?message=invalid_request'
end
+
+ it 'should include the origin (escaped) if one is provided' do
+ env.merge! 'omniauth.origin' => '/origin-example'
+ status, head, body = *subject.call(env)
+ head['Location'].should be_include('&origin=%2Forigin-example')
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.