Skip to content

Commit

Permalink
* Refactor params_enabled? so that the single_access_allowed? method …
Browse files Browse the repository at this point in the history
…in controllers takes precedence.
  • Loading branch information
binarylogic committed Apr 24, 2009
1 parent a2cbda6 commit bf42553
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

== 2.0.6 release 2009-4-9

* Don't use second, use [1] instead so older rails systems don't complain.
* Don't use second, use [1] instead so older rails versions don't complain.
* Update email regular expression to be less TLD specific: (?:[A-Z]{2,4}|museum|travel)
* Update shoulda macro for 2.0
* validates_length_of_password_confirmation_field_options defaults to validates_confirmation_of_password_field_options
Expand Down
6 changes: 5 additions & 1 deletion lib/authlogic/controller_adapters/abstract_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ def session
controller.session
end

def responds_to_single_access_allowed?
controller.respond_to?(:single_access_allowed?, true)
end

def single_access_allowed?
controller.respond_to?(:single_access_allowed?, true) && controller.send(:single_access_allowed?)
controller.send(:single_access_allowed?)
end

private
Expand Down
13 changes: 9 additions & 4 deletions lib/authlogic/session/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ def persist_by_params
end

def params_enabled?
params_credentials && klass.column_names.include?("single_access_token") &&
(single_access_allowed_request_types.include?(controller.request_content_type) ||
single_access_allowed_request_types.include?(:all) || single_access_allowed_request_types == :all ||
controller.single_access_allowed?)
return false if !params_credentials || !klass.column_names.include?("single_access_token")
return controller.single_access_allowed? if controller.responds_to_single_access_allowed?

case single_access_allowed_request_types
when Array
single_access_allowed_request_types.include?(controller.request_content_type) || single_access_allowed_request_types.include?(:all)
else
single_access_allowed_request_types == :all
end
end

def params_key
Expand Down

0 comments on commit bf42553

Please sign in to comment.