Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Release v2.0

  • Loading branch information...
commit 6944fe557c695923b988db775978ad8444e5c5bb 1 parent 78f5bef
@binarylogic binarylogic authored
View
13 lib/authlogic/acts_as_authentic/base.rb
@@ -1,6 +1,6 @@
module Authlogic
module ActsAsAuthentic
- # Adds in the acts_as_authentic method to ActiveRecord.
+ # Provides the base functionality for acts_as_authentic
module Base
def self.included(klass)
klass.class_eval do
@@ -27,14 +27,21 @@ def acts_as_authentic(&block)
yield self if block_given?
acts_as_authentic_modules.each { |mod| include mod }
end
-
+
+ # Since this part of Authlogic deals with another class, ActiveRecord, we can't just start including things
+ # in ActiveRecord itself. A lot of these module includes need to be triggered by the acts_as_authentic method
+ # call. For example, you don't want to start adding in email validations and what not into a model that has
+ # nothing to do with Authlogic.
+ #
+ # That being said, this is your tool for extending Authlogic and "hooking" into the acts_as_authentic call.
def add_acts_as_authentic_module(mod)
modules = acts_as_authentic_modules
modules << mod
modules.uniq!
write_inheritable_attribute(:acts_as_authentic_modules, modules)
end
-
+
+ # This is the same as add_acts_as_authentic_module, except that it removes the module from the list.
def remove_acts_as_authentic_module(mod)
acts_as_authentic_modules.delete(mod)
acts_as_authentic_modules
View
1  lib/authlogic/acts_as_authentic/password.rb
@@ -11,6 +11,7 @@ def self.included(klass)
end
end
+ # All configuration for the password aspect of acts_as_authentic.
module Config
# The name of the crypted_password field in the database.
#
View
2  lib/authlogic/acts_as_authentic/single_access_token.rb
@@ -10,6 +10,7 @@ def self.included(klass)
end
end
+ # All configuration for the single_access token aspect of acts_as_authentic.
module Config
def change_single_access_token_with_password(value = nil)
config(:change_single_access_token_with_password, value, false)
@@ -17,6 +18,7 @@ def change_single_access_token_with_password(value = nil)
alias_method :change_single_access_token_with_password=, :change_single_access_token_with_password
end
+ # All method, for the single_access token aspect of acts_as_authentic.
module Methods
def self.included(klass)
return if !klass.column_names.include?("single_access_token")
View
9 test/session_test/session_test.rb
@@ -20,6 +20,15 @@ def test_persist_persist_by_session
assert_equal ben, session.record
assert_equal ben.persistence_token, @controller.session["user_credentials"]
end
+
+ def test_persist_persist_by_session_with_token_only
+ ben = users(:ben)
+ set_session_for(ben)
+ @controller.session["user_credentials_id"] = nil
+ assert session = UserSession.find
+ assert_equal ben, session.record
+ assert_equal ben.persistence_token, @controller.session["user_credentials"]
+ end
def test_after_save_update_session
ben = users(:ben)
Please sign in to comment.
Something went wrong with that request. Please try again.