Permalink
Browse files

Allow for login_count to be nil and initialize with 1

  • Loading branch information...
1 parent 6af9b61 commit 2479aa05f68450d791be3688acfa8fcccc7ae0b2 @binarylogic committed Nov 3, 2008
Showing with 18 additions and 6 deletions.
  1. +5 −0 CHANGELOG.rdoc
  2. +5 −5 README.rdoc
  3. +7 −0 lib/authlogic/active_record/acts_as_authentic.rb
  4. +1 −1 lib/authlogic/session/base.rb
View
@@ -1,3 +1,8 @@
+== 0.10.5 released 2008-10-31
+
+* Checked for blank login counts, if a default wasnt set in the migrations.
+* Added check for database table in acts_as_authentic to avoid errors in initial setup.
+
== 0.10.4 released 2008-10-31
* Changed configuration to use inheritable attributes
View
@@ -136,7 +136,7 @@ Authlogic tries to check the state of the record before creating the session. If
What's neat about this is that these are checked upon any type of login. When logging in explicitly, by cookie, session, or basic http auth. So if you mark a user inactive in the middle of their session they wont be logged back in next time they refresh the page. Giving you complete control.
-Need Authlogic to check your own "state"? No problem, check out the hooks section below. Add in a before_validation or after_validation to do your own checking.
+Need Authlogic to check your own "state"? No problem, check out the hooks section below. Add in a before_validation to do your own checking. The sky is the limit.
== Hooks / Callbacks
@@ -204,7 +204,7 @@ This scopes your login field validation, so that users are allowed to have the s
=== Scoping your session
-When you session tries to validate it searches for a record. You want to scope that search. No problem...
+When the session tries to validate it searches for a record. You want to scope that search. No problem...
The goal of Authlogic was to not try and introduce anything new. As a result I came up with:
@@ -221,9 +221,9 @@ This works just like ActiveRecord, so it should come natural. Here is how you ge
=== Scoping cookies
-What's neat about cookies is that if you use sub domains they automatically scope their self. Meaning if you create a cookie in whatever.yourdomain.com it will not exist in another.yourdomain.com. So if you have the example used above, where you can access accounts via a sub domain, you don't have to do anything.
+What's neat about cookies is that if you use sub domains they automatically scope their self. Meaning if you create a cookie in whatever.yourdomain.com it will not exist in another.yourdomain.com. So if you are using subdomains to scope your users, you don't have to do anything.
-But what if you don't want to separate your cookies by subdomains? You can accomplish this by doing:
+But what if you *don't* want to separate your cookies by subdomains? You can accomplish this by doing:
ActionController::Base.session_options[:session_domain] = ‘.mydomain.com’
@@ -237,7 +237,7 @@ Now let's look at this from the other angle. What if you are *NOT* using subdoma
Done, Authlogic will give each cookie a unique name depending on the account.
-With the above information you should be able to scope your sessions any way you want. Just mix and match the tools above to accomplish what you want. Also check out the documentation on Authlogic::ActiveRecord::AuthenticatesMany.
+With the above information you should be able to scope your sessions any way you want. Just mix and match the tools above to accomplish this. Also check out the documentation on Authlogic::ActiveRecord::AuthenticatesMany.
== Errors
@@ -45,6 +45,13 @@ module ActsAsAuthentic
# * <tt>logged_in_timeout:</tt> default: 10.minutes, this allows you to specify a time the determines if a user is logged in or out. Useful if you want to count how many users are currently logged in.
# * <tt>session_ids:</tt> default: [nil], the sessions that we want to automatically reset when a user is created or updated so you don't have to worry about this. Set to [] to disable. Should be an array of ids. See Authlogic::Session::Base#initialize for information on ids. The order is important. The first id should be your main session, the session they need to log into first. This is generally nil, meaning so explicitly set id.
def acts_as_authentic(options = {})
+ # If we don't have a database, skip all of this
+ begin
+ column_names
+ rescue Exception
+ return
+ end
+
# Setup default options
options[:session_class] ||= "#{name}Session".constantize
options[:crypto_provider] ||= Sha512CryptoProvider
@@ -313,7 +313,7 @@ def save
:expires => remember_me_until
}
- record.login_count = record.login_count + 1 if record.respond_to?(:login_count)
+ record.login_count = (record.login_count.blank? ? 1 : record.login_count + 1) if record.respond_to?(:login_count)
if record.respond_to?(:current_login_at)
record.last_login_at = record.current_login_at if record.respond_to?(:last_login_at)

0 comments on commit 2479aa0

Please sign in to comment.