Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -21,7 +21,7 @@ def request
def raw_session
request.session
end
-
+
def reset_session!
raw_session.inspect # why do I have to inspect it to get it to clear?
raw_session.clear
@@ -32,6 +32,14 @@ def reset_session!
env['warden'].request.params['action'] = RailsWarden.unauthenticated_action || "unauthenticated"
end
+# Rails needs the action to be passed in with the params
+Warden::Manager.before_failure do |env, opts|
+ if request = env["action_controller.rescue.request"]
+ request.params["action"] = RailsWarden.unauthenticated_action
+ end
+end
+
+
if defined?(Rails)
Rails.configuration.after_initialize do
class ActionController::Base
19 lib/rails_warden/manager.rb
View
@@ -1,31 +1,24 @@
# encoding: utf-8
module RailsWarden
class Manager
-
+
def self.new(app, opts = {}, &block)
# Get the failure application
opts[:failure_app] = opts[:failure_app].to_s.classify.constantize if opts[:failure_app]
opts[:default_strategies] = [opts[:defaults]].flatten if opts[:defaults]
-
+
# Set the default user
if user = opts.delete(:default_user)
RailsWarden.default_user_class = user.to_s.classify.constantize
end
-
+
# Set the unauthenticated action if it's set
if ua = opts.delete(:unauthenticated_action)
RailsWarden.unauthenticated_action = ua
end
-
- # Rails needs the action to be passed in with the params
- Warden::Manager.before_failure do |env, opts|
- if request = env["action_controller.rescue.request"]
- request.params["action"] = RailsWarden.unauthenticated_action
- end
- end
-
+
Warden::Manager.new(app, opts, &block)
end
-
+
end
-end
+end
9 rails_warden.gemspec
View
@@ -1,15 +1,15 @@
# Generated by jeweler
-# DO NOT EDIT THIS FILE
-# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{rails_warden}
- s.version = "0.2.4"
+ s.version = "0.2.5"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Daniel Neighman"]
- s.date = %q{2009-09-09}
+ s.date = %q{2009-11-17}
s.description = %q{A gem that provides authenitcation via the Warden framework}
s.email = %q{has.sox@gmail.com}
s.extra_rdoc_files = [
@@ -57,3 +57,4 @@ Gem::Specification.new do |s|
else
end
end
+
10 spec/rails_warden_spec.rb
View
@@ -54,4 +54,14 @@ class ::User
)
RailsWarden.unauthenticated_action.should == "unauthenticated"
end
+
+ it "should not add a before_failure callback each time it is created" do
+ original_number_of_callbacks = Warden::Manager._before_failure.size
+
+ RailsWarden::Manager.new(@app, :failure_app => "foo_failure",
+ :defaults => :password)
+
+ Warden::Manager._before_failure.size.should == original_number_of_callbacks
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.