Fixed user tracking in authenticate method
Andrew Kane
committed Jul 10, 2014
commit c18ff478c992f02e735136b4467ecea635655b51
Showing 2
changed files with
9 additions
and 11 deletions
ahoy.rb b/lib/ahoy.rb
+0
-6
| @@ | @@ -56,14 +56,8 @@ module Ahoy |
| # deprecated | |
| mattr_accessor :domain | |
| - | |
| mattr_accessor :visit_model | |
| - | |
| mattr_accessor :user_method | |
| - | self.user_method = proc do |controller| |
| - | (controller.respond_to?(:current_user) && controller.current_user) || (controller.respond_to?(:current_resource_owner, true) && controller.send(:current_resource_owner)) || nil |
| - | end |
| - | |
| mattr_accessor :exclude_method | |
| mattr_accessor :subscribers | |
ahoy/stores/active_record_token_store.rb b/lib/ahoy/stores/active_record_token_store.rb
+9
-5
| @@ | @@ -77,11 +77,15 @@ module Ahoy |
| end | |
| def user | |
| - | user_method = Ahoy.user_method |
| - | if user_method.respond_to?(:call) |
| - | user_method.call(controller) |
| - | else |
| - | controller.send(user_method) |
| + | @user ||= begin |
| + | user_method = Ahoy.user_method |
| + | if user_method.respond_to?(:call) |
| + | user_method.call(controller) |
| + | elsif user_method |
| + | controller.send(user_method) |
| + | else |
| + | super |
| + | end |
| end | |
| end | |