Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Release v2.0.4

  • Loading branch information...
commit 281ec5c4b3eab399e44ac6c8d5f0875cfda9793e 1 parent 8a39ac4
@binarylogic authored
View
2  CHANGELOG.rdoc
@@ -1,4 +1,4 @@
-== 2.0.4
+== 2.0.4 released 2009-3-28
* Added validates_uniqueness_of_login_field_options and validates_uniqueness_of_email_field_options configuration options
* Add in checks to make sure session_class is not nil.
View
1  Manifest.txt
@@ -55,6 +55,7 @@ lib/authlogic/session/timeout.rb
lib/authlogic/session/unauthorized_record.rb
lib/authlogic/session/validation.rb
lib/authlogic/test_case.rb
+lib/authlogic/test_case/controller_adapter.rb
lib/authlogic/test_case/mock_controller.rb
lib/authlogic/test_case/mock_cookie_jar.rb
lib/authlogic/test_case/mock_request.rb
View
8 README.rdoc
@@ -63,7 +63,7 @@ These modules are for the acts_as_authentic method you call in your model. It co
These modules are for the "session side" of authentication. They create a new domain for session logic, allowing you to create, destroy, and ultimately manage your sessions.
* Authlogic::Session::BruteForceProtection - Disables accounts after a certain number of consecutive failed logins attempted.
-* Authlogic::Session::Callbacks - Your tools to extend, change, or add onto Authlogic. Lets you hook in and do just about anything you want.
+* Authlogic::Session::Callbacks - Your tools to extend, change, or add onto Authlogic. Lets you hook in and do just about anything you want. Start here if you want to write a plugin or add on for Authlogic
* Authlogic::Session::Cookies - Authentication via cookies.
* Authlogic::Session::Existence - Creating, saving, and destroying objects.
* Authlogic::Session::HttpAuth - Authentication via basic HTTP authentication.
@@ -184,9 +184,9 @@ This will create a file that looks similar to:
The user model should have the following columns. The names of these columns can be changed with configuration. Better yet, Authlogic tries to guess these names by checking for the existence of common names. See the sub modules of Authlogic::Session for more details, but chances are you won't have to specify any configuration for your field names, even if they aren't the same names as below.
t.string :login, :null => false # optional, you can use email instead, or both
- t.string :crypted_password, :null => false
+ t.string :crypted_password, :null => false # required
t.string :password_salt, :null => false # optional, but highly recommended
- t.string :persistence_token, :null => false
+ t.string :persistence_token, :null => false # required
t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
@@ -221,7 +221,7 @@ Here are some common next steps. They might or might not apply to you. For a com
6. Need to reset passwords or activate accounts? Use the perishable token. See Authlogic::ActsAsAuthentic::PerishableToken
7. Need to give API access or access to a private feed? Use basic HTTP auth or authentication by params. See Authlogic::Session::HttpAuth or Authlogic::Session::Params
8. Need to internationalize your app? See Authlogic::I18n
-9. Need help testing? See the Authlogic::Testing
+9. Need help testing? See the Authlogic::TestCase
== Interested in how it works?
View
2  lib/authlogic/session/activation.rb
@@ -29,6 +29,8 @@ def activated?
# This accepts a controller object wrapped with the Authlogic controller adapter. The controller adapters close the gap
# between the different controllers in each framework. That being said, Authlogic is expecting your object's class to
# extend Authlogic::ControllerAdapters::AbstractAdapter. See Authlogic::ControllerAdapters for more info.
+ #
+ # Lastly, this is thread safe.
def controller=(value)
Thread.current[:authlogic_controller] = value
end
View
8 lib/authlogic/session/active_record_trickery.rb
@@ -11,12 +11,19 @@ def self.included(klass)
end
module ClassMethods
+ # How to name the attributes of Authlogic, works JUST LIKE ActiveRecord, but instead it uses the following
+ # namespace:
+ #
+ # authlogic.attributes.user_session.login
def human_attribute_name(attribute_key_name, options = {})
options[:count] ||= 1
options[:default] ||= attribute_key_name.humanize
I18n.t("attributes.#{name.underscore}.#{attribute_key_name}", options)
end
+ # How to name the class, works JUST LIKE ActiveRecord, except it uses the following namespace:
+ #
+ # authlogic.models.user_session
def human_name(*args)
I18n.t("models.#{name.underscore}", {:count => 1, :default => name.humanize})
end
@@ -33,6 +40,7 @@ def self_and_descendants_from_active_record
end
module InstanceMethods
+ # Don't use this yourself, this is to just trick some of the helpers since this is the method it calls.
def new_record?
new_session?
end
View
5 lib/authlogic/session/callbacks.rb
@@ -1,12 +1,11 @@
module Authlogic
module Session
# Between these callsbacks and the configuration, this is the contract between me and you to safely
- # modify Authlogic's behavior. The ONLY reason these things will change is during a big version upgrade.
- # For example, going from v1.X.X to 2.0.0.
+ # modify Authlogic's behavior. I will do everything I can to make sure these do not change.
#
# Check out the sub modules of Authlogic::Session. They are very concise, clear, and to the point. More
# importantly they use the same API that you would use to extend Authlogic. That being said, they are great
- # examples of how to extend Authlogic and add / modify behavior. These modules could easily be pulled out
+ # examples of how to extend Authlogic and add / modify behavior to Authlogic. These modules could easily be pulled out
# into their own plugin and become an "add on" without any change.
#
# Now to the point of this module. Just like in ActiveRecord you have before_save, before_validation, etc.
View
10 lib/authlogic/session/cookies.rb
@@ -1,6 +1,6 @@
module Authlogic
module Session
- # Handles all authentication that deals with cookies, such as persisting a session and saving / destroying a session.
+ # Handles all authentication that deals with cookies, such as persisting, saving, and destroying.
module Cookies
def self.included(klass)
klass.class_eval do
@@ -50,7 +50,8 @@ def remember_me_for(value = :_read)
end
# The methods available for an Authlogic::Session::Base object that make up the cookie feature set.
- module InstanceMethods
+ module InstanceMethods
+ # Allows you to set the remember_me option when passing credentials.
def credentials=(value)
super
values = value.is_a?(Array) ? value : [value]
@@ -63,7 +64,8 @@ def credentials=(value)
end
end
- def remember_me # :nodoc:
+ # Is the cookie going to expire after the session is over, or will it stick around?
+ def remember_me
return @remember_me if defined?(@remember_me)
@remember_me = self.class.remember_me
end
@@ -73,7 +75,7 @@ def remember_me=(value)
@remember_me = value
end
- # Allows users to be remembered via a cookie.
+ # See remember_me
def remember_me?
remember_me == true || remember_me == "true" || remember_me == "1"
end
View
5 lib/authlogic/session/existence.rb
@@ -20,7 +20,7 @@ module ClassMethods
# A convenince method. The same as:
#
# session = UserSession.new(*args)
- # session.create
+ # session.save
#
# Instead you can do:
#
@@ -49,7 +49,8 @@ def destroy
true
end
- # Returns true if the session has not been saved yet.
+ # Returns true if the session is new, meaning no action has been taken on it and a successful save
+ # has not taken place.
def new_session?
new_session != false
end
View
4 lib/authlogic/session/validation.rb
@@ -10,7 +10,7 @@ module Validation
# private
# def check_if_awesome
# errors.add(:login, "must contain awesome") if login && !login.include?("awesome")
- # errors.add_to_base("You must be awesome to log in") unless record.awesome?
+ # errors.add_to_base("You must be awesome to log in") unless attempted_record.awesome?
# end
# end
class Errors < ::ActiveRecord::Errors
@@ -39,7 +39,7 @@ def attempted_record=(value)
# private
# def check_if_awesome
# errors.add(:login, "must contain awesome") if login && !login.include?("awesome")
- # errors.add_to_base("You must be awesome to log in") unless record.awesome?
+ # errors.add_to_base("You must be awesome to log in") unless attempted_record.awesome?
# end
# end
def errors
View
4 lib/authlogic/test_case.rb
@@ -59,7 +59,9 @@ module Authlogic
#
# require "authlogic/test_case"
module TestCase
- # Activates authlogic with an Authlogic::TestCase::MockController object.
+ # Activates authlogic so that you can use it in your tests. You should call this method in your test's setup. Ex:
+ #
+ # setup :activate_authlogic
def activate_authlogic
Authlogic::Session::Base.controller = (@request && Authlogic::TestCase::ControllerAdapter.new(@request)) || controller
end
View
4 lib/authlogic/test_case/controller_adapter.rb
@@ -1,7 +1,7 @@
module Authlogic
module TestCase
- # Adapts authlogic to work with rails. The point is to close the gap between what authlogic expects and what the rails controller object
- # provides. Similar to how ActiveRecord has an adapter for MySQL, PostgreSQL, SQLite, etc.
+ # Adapts authlogic to work with the @request object when testing. This way Authlogic can set cookies and what not before
+ # a request is made, ultimately letting you log in users in functional tests.
class ControllerAdapter < ControllerAdapters::AbstractAdapter
def authenticate_with_http_basic(&block)
controller.authenticate_with_http_basic(&block)
View
2  lib/authlogic/test_case/mock_controller.rb
@@ -1,5 +1,7 @@
module Authlogic
module TestCase
+ # Basically acts like a controller but doesn't do anything. Authlogic can interact with this, do it's thing and then you
+ # can look at the controller object to see if anything changed.
class MockController < ControllerAdapters::AbstractAdapter
attr_accessor :http_user, :http_password
attr_writer :request_content_type
View
2  lib/authlogic/test_case/mock_cookie_jar.rb
@@ -1,6 +1,6 @@
module Authlogic
module TestCase
- class MockCookieJar < Hash
+ class MockCookieJar < Hash # :nodoc:
def [](key)
hash = super
hash && hash[:value]
View
2  lib/authlogic/test_case/mock_request.rb
@@ -1,6 +1,6 @@
module Authlogic
module TestCase
- class MockRequest
+ class MockRequest # :nodoc:
def remote_ip
"1.1.1.1"
end
View
7 lib/authlogic/version.rb
@@ -1,11 +1,8 @@
module Authlogic # :nodoc:
- # = Version
- #
# A class for describing the current version of a library. The version
# consists of three parts: the +major+ number, the +minor+ number, and the
# +tiny+ (or +patch+) number.
class Version
-
include Comparable
# A convenience method for instantiating a new Version instance with the
@@ -44,13 +41,11 @@ def to_a
MAJOR = 2
MINOR = 0
- TINY = 3
+ TINY = 4
# The current version as a Version instance
CURRENT = new(MAJOR, MINOR, TINY)
# The current version as a String
STRING = CURRENT.to_s
-
end
-
end
Please sign in to comment.
Something went wrong with that request. Please try again.