Permalink
Browse files

Use prepend_before_filter in require_no_authentication.

We need to be sure require_no_authentication runs before other user filters that may call some Devise helper (ie current_xxx).

Conflicts:

	app/controllers/devise/passwords_controller.rb
	app/controllers/devise/registrations_controller.rb
	app/controllers/devise/sessions_controller.rb
	app/controllers/devise/unlocks_controller.rb
	lib/devise/controllers/internal_helpers.rb
	test/rails_app/app/controllers/application_controller.rb
  • Loading branch information...
carlosantoniodasilva committed Mar 26, 2010
1 parent ca4e093 commit a5ba2ac1a883404595e33960aa21e577ad8d6b79
@@ -1,8 +1,7 @@
class Devise::PasswordsController < ApplicationController
+ prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
- before_filter :require_no_authentication
-
# GET /resource/password/new
def new
build_resource
@@ -1,9 +1,8 @@
class Devise::RegistrationsController < ApplicationController
+ prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
+ prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
include Devise::Controllers::InternalHelpers
- before_filter :require_no_authentication, :only => [ :new, :create ]
- before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
-
# GET /resource/sign_up
def new
build_resource
@@ -1,8 +1,7 @@
class Devise::SessionsController < ApplicationController
+ prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
include Devise::Controllers::InternalHelpers
- before_filter :require_no_authentication, :only => [ :new, :create ]
-
# GET /resource/sign_in
def new
unless resource_just_signed_up?
@@ -35,11 +34,11 @@ def destroy
protected
- def resource_just_signed_up?
- flash[:"#{resource_name}_signed_up"]
- end
+ def resource_just_signed_up?
+ flash[:"#{resource_name}_signed_up"]
+ end
- def clean_up_passwords(object)
- object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
- end
+ def clean_up_passwords(object)
+ object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
+ end
end
@@ -1,8 +1,7 @@
class Devise::UnlocksController < ApplicationController
+ prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
- before_filter :require_no_authentication
-
# GET /resource/unlock/new
def new
build_resource
@@ -12,11 +12,10 @@ module InternalHelpers #:nodoc:
helpers = %w(resource scope_name resource_name
resource_class devise_mapping devise_controller?)
-
hide_action *helpers
helper_method *helpers
- before_filter :is_devise_resource?
+ prepend_before_filter :is_devise_resource?
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
end
@@ -24,6 +24,10 @@ def authenticate!(*args)
catch_with_redirect { super }
end
+ def user(*args)
+ catch_with_redirect { super }
+ end
+
def catch_with_redirect(&block)
result = catch(:warden, &block)
@@ -3,4 +3,6 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ before_filter :current_user
end

0 comments on commit a5ba2ac

Please sign in to comment.