Permalink
Browse files

updates the defaults when setting scope_defaults to allow the action …

…to be specified on failure
  • Loading branch information...
1 parent 87f11f9 commit 9ae59b4997ca618e78bee507d7a4232118ead8d1 @hassox committed May 14, 2010
Showing with 30 additions and 5 deletions.
  1. +3 −1 .gitignore
  2. +1 −1 lib/warden/manager.rb
  3. +1 −0 lib/warden/proxy.rb
  4. +1 −0 lib/warden/test/helpers.rb
  5. +1 −1 lib/warden/version.rb
  6. +21 −0 spec/warden/proxy_spec.rb
  7. +2 −2 warden.gemspec
View
@@ -1,3 +1,5 @@
.DS_Store
pkg
-.*~
+.*~
+
+*.gem
View
@@ -87,7 +87,7 @@ def serialize_from_session(&block)
# It looks at the result of the proxy to see if it's been executed and what action to take.
# :api: private
def process_unauthenticated(env, options={})
- options[:action] ||= :unauthenticated
+ options[:action] ||= "unauthenticated"
proxy = env['warden']
result = options[:result] || proxy.result
View
@@ -269,6 +269,7 @@ def _perform_authentication(*args)
def _retrieve_scope_and_opts(args) #:nodoc:
opts = args.last.is_a?(Hash) ? args.pop : {}
scope = opts[:scope] || @config.default_scope
+ opts = (config[:scope_defaults][scope] || {}).merge(opts)
[scope, opts]
end
@@ -16,6 +16,7 @@ def self.included(base)
# @api public
def login_as(user, opts = {})
Warden.on_next_request do |proxy|
+ opts[:event] ||= :authentication
proxy.set_user(user, opts)
end
end
View
@@ -1,4 +1,4 @@
# encoding: utf-8
module Warden
- VERSION = "0.10.2".freeze
+ VERSION = "0.10.4".freeze
end
View
@@ -773,6 +773,27 @@ def wrap_app(app, &blk)
end
describe "default scope options" do
+
+ it "should allow me to set a default action for a given scope" do
+ $captures = []
+ builder = Rack::Builder.new do
+ use Warden::Manager do |config|
+ config.scope_defaults :foo, :strategies => [:two], :action => "some_bad_action"
+ config.failure_app = Warden::Spec::Helpers::FAILURE_APP
+ end
+
+ run(lambda do |e|
+ e['warden'].authenticate!(:scope => :foo)
+ end)
+ end
+
+ env = env_with_params("/foo")
+ env["rack.session"] = {}
+ builder.to_app.call(env)
+ request = Rack::Request.new(env)
+ request.path.should == "/some_bad_action"
+ end
+
it "should allow me to set store, false on a given scope" do
$captures = []
builder = Rack::Builder.new do
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{warden}
- s.version = "0.10.2"
+ s.version = "0.10.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Daniel Neighman"]
- s.date = %q{2010-03-26}
+ s.date = %q{2010-05-14}
s.email = %q{has.sox@gmail.com}
s.extra_rdoc_files = [
"LICENSE",

0 comments on commit 9ae59b4

Please sign in to comment.