Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updates to fix issue 3. Thanx vandrijevik (Vladimir Andrijevik) and t…

…mm1 (Aman Gupta)
  • Loading branch information...
commit 35de07f46ccdf11970bae8ece0307d6b1f538c6e 1 parent 4b6248e
Daniel Neighman hassox authored
10 lib/rails_warden.rb
@@ -21,7 +21,7 @@ def request
21 21 def raw_session
22 22 request.session
23 23 end
24   -
  24 +
25 25 def reset_session!
26 26 raw_session.inspect # why do I have to inspect it to get it to clear?
27 27 raw_session.clear
@@ -32,6 +32,14 @@ def reset_session!
32 32 env['warden'].request.params['action'] = RailsWarden.unauthenticated_action || "unauthenticated"
33 33 end
34 34
  35 +# Rails needs the action to be passed in with the params
  36 +Warden::Manager.before_failure do |env, opts|
  37 + if request = env["action_controller.rescue.request"]
  38 + request.params["action"] = RailsWarden.unauthenticated_action
  39 + end
  40 +end
  41 +
  42 +
35 43 if defined?(Rails)
36 44 Rails.configuration.after_initialize do
37 45 class ActionController::Base
19 lib/rails_warden/manager.rb
... ... @@ -1,31 +1,24 @@
1 1 # encoding: utf-8
2 2 module RailsWarden
3 3 class Manager
4   -
  4 +
5 5 def self.new(app, opts = {}, &block)
6 6 # Get the failure application
7 7 opts[:failure_app] = opts[:failure_app].to_s.classify.constantize if opts[:failure_app]
8 8 opts[:default_strategies] = [opts[:defaults]].flatten if opts[:defaults]
9   -
  9 +
10 10 # Set the default user
11 11 if user = opts.delete(:default_user)
12 12 RailsWarden.default_user_class = user.to_s.classify.constantize
13 13 end
14   -
  14 +
15 15 # Set the unauthenticated action if it's set
16 16 if ua = opts.delete(:unauthenticated_action)
17 17 RailsWarden.unauthenticated_action = ua
18 18 end
19   -
20   - # Rails needs the action to be passed in with the params
21   - Warden::Manager.before_failure do |env, opts|
22   - if request = env["action_controller.rescue.request"]
23   - request.params["action"] = RailsWarden.unauthenticated_action
24   - end
25   - end
26   -
  19 +
27 20 Warden::Manager.new(app, opts, &block)
28 21 end
29   -
  22 +
30 23 end
31   -end
  24 +end
9 rails_warden.gemspec
... ... @@ -1,15 +1,15 @@
1 1 # Generated by jeweler
2   -# DO NOT EDIT THIS FILE
3   -# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
  2 +# DO NOT EDIT THIS FILE DIRECTLY
  3 +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4 4 # -*- encoding: utf-8 -*-
5 5
6 6 Gem::Specification.new do |s|
7 7 s.name = %q{rails_warden}
8   - s.version = "0.2.4"
  8 + s.version = "0.2.5"
9 9
10 10 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11 11 s.authors = ["Daniel Neighman"]
12   - s.date = %q{2009-09-09}
  12 + s.date = %q{2009-11-17}
13 13 s.description = %q{A gem that provides authenitcation via the Warden framework}
14 14 s.email = %q{has.sox@gmail.com}
15 15 s.extra_rdoc_files = [
@@ -57,3 +57,4 @@ Gem::Specification.new do |s|
57 57 else
58 58 end
59 59 end
  60 +
10 spec/rails_warden_spec.rb
@@ -54,4 +54,14 @@ class ::User
54 54 )
55 55 RailsWarden.unauthenticated_action.should == "unauthenticated"
56 56 end
  57 +
  58 + it "should not add a before_failure callback each time it is created" do
  59 + original_number_of_callbacks = Warden::Manager._before_failure.size
  60 +
  61 + RailsWarden::Manager.new(@app, :failure_app => "foo_failure",
  62 + :defaults => :password)
  63 +
  64 + Warden::Manager._before_failure.size.should == original_number_of_callbacks
  65 + end
  66 +
57 67 end

0 comments on commit 35de07f

Please sign in to comment.
Something went wrong with that request. Please try again.