Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use iso8601 for cookie remember_me_until

  • Loading branch information...
commit e78123721720e1073a534c5ee943bb17be1f8d5f 1 parent 6592f3a
@binarylogic authored
View
8 Appraisals
@@ -1,9 +1,9 @@
appraise "rails3" do
- gem "activerecord", "3.2.14"
- gem "activesupport", "3.2.14"
+ gem "activerecord", "3.2.17"
+ gem "activesupport", "3.2.17"
end
appraise "rails4" do
- gem "activerecord", "4.0.0"
- gem "activesupport", "4.0.0"
+ gem "activerecord", "4.0.3"
+ gem "activesupport", "4.0.3"
end
View
58 Gemfile.lock
@@ -8,30 +8,46 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- activemodel (3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
- activerecord (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activesupport (3.2.13)
- i18n (= 0.6.1)
- multi_json (~> 1.0)
+ activemodel (4.0.3)
+ activesupport (= 4.0.3)
+ builder (~> 3.1.0)
+ activerecord (4.0.3)
+ activemodel (= 4.0.3)
+ activerecord-deprecated_finders (~> 1.0.2)
+ activesupport (= 4.0.3)
+ arel (~> 4.0.0)
+ activerecord-deprecated_finders (1.0.3)
+ activesupport (4.0.3)
+ i18n (~> 0.6, >= 0.6.4)
+ minitest (~> 4.2)
+ multi_json (~> 1.3)
+ thread_safe (~> 0.1)
+ tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
- arel (3.0.2)
- bcrypt-ruby (3.0.1)
- builder (3.0.4)
- i18n (0.6.1)
- multi_json (1.7.2)
- rake (10.0.4)
- scrypt (1.1.0)
- sqlite3 (1.3.7)
- timecop (0.6.1)
- tzinfo (0.3.37)
+ arel (4.0.2)
+ atomic (1.1.15)
+ bcrypt (3.1.7)
+ bcrypt-ruby (3.1.5)
+ bcrypt (>= 3.1.3)
+ builder (3.1.4)
+ ffi (1.9.3)
+ ffi-compiler (0.1.3)
+ ffi (>= 1.0.0)
+ rake
+ i18n (0.6.9)
+ minitest (4.7.5)
+ multi_json (1.8.4)
+ rake (10.1.1)
+ scrypt (1.2.0)
+ ffi-compiler (>= 0.0.2)
+ rake
+ sqlite3 (1.3.9)
+ thread_safe (0.2.0)
+ atomic (>= 1.1.7, < 2)
+ timecop (0.7.1)
+ tzinfo (0.3.38)
PLATFORMS
ruby
View
4 gemfiles/rails3.gemfile
@@ -2,7 +2,7 @@
source "https://rubygems.org"
-gem "activerecord", "3.2.14"
-gem "activesupport", "3.2.14"
+gem "activerecord", "3.2.17"
+gem "activesupport", "3.2.17"
gemspec :path=>"../"
View
44 gemfiles/rails3.gemfile.lock
@@ -1,5 +1,5 @@
PATH
- remote: /Users/benjohnson/projects/binarylogic/authlogic
+ remote: ../
specs:
authlogic (3.3.0)
activerecord (>= 3.2)
@@ -8,37 +8,45 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- activemodel (3.2.14)
- activesupport (= 3.2.14)
+ activemodel (3.2.17)
+ activesupport (= 3.2.17)
builder (~> 3.0.0)
- activerecord (3.2.14)
- activemodel (= 3.2.14)
- activesupport (= 3.2.14)
+ activerecord (3.2.17)
+ activemodel (= 3.2.17)
+ activesupport (= 3.2.17)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activesupport (3.2.14)
+ activesupport (3.2.17)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
appraisal (0.5.2)
bundler
rake
- arel (3.0.2)
- bcrypt-ruby (3.0.1)
+ arel (3.0.3)
+ bcrypt (3.1.7)
+ bcrypt-ruby (3.1.5)
+ bcrypt (>= 3.1.3)
builder (3.0.4)
- i18n (0.6.4)
- multi_json (1.7.7)
- rake (10.1.0)
- scrypt (1.1.0)
- sqlite3 (1.3.7)
- timecop (0.6.2.2)
- tzinfo (0.3.37)
+ ffi (1.9.3)
+ ffi-compiler (0.1.3)
+ ffi (>= 1.0.0)
+ rake
+ i18n (0.6.9)
+ multi_json (1.8.4)
+ rake (10.1.1)
+ scrypt (1.2.0)
+ ffi-compiler (>= 0.0.2)
+ rake
+ sqlite3 (1.3.9)
+ timecop (0.7.1)
+ tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
- activerecord (= 3.2.14)
- activesupport (= 3.2.14)
+ activerecord (= 3.2.17)
+ activesupport (= 3.2.17)
appraisal
authlogic!
bcrypt-ruby
View
4 gemfiles/rails4.gemfile
@@ -2,7 +2,7 @@
source "https://rubygems.org"
-gem "activerecord", "4.0.0"
-gem "activesupport", "4.0.0"
+gem "activerecord", "4.0.3"
+gem "activesupport", "4.0.3"
gemspec :path=>"../"
View
50 gemfiles/rails4.gemfile.lock
@@ -1,5 +1,5 @@
PATH
- remote: /Users/benjohnson/projects/binarylogic/authlogic
+ remote: ../
specs:
authlogic (3.3.0)
activerecord (>= 3.2)
@@ -8,16 +8,16 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- activemodel (4.0.0)
- activesupport (= 4.0.0)
+ activemodel (4.0.3)
+ activesupport (= 4.0.3)
builder (~> 3.1.0)
- activerecord (4.0.0)
- activemodel (= 4.0.0)
+ activerecord (4.0.3)
+ activemodel (= 4.0.3)
activerecord-deprecated_finders (~> 1.0.2)
- activesupport (= 4.0.0)
+ activesupport (= 4.0.3)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
- activesupport (4.0.0)
+ activesupport (4.0.3)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
@@ -26,27 +26,35 @@ GEM
appraisal (0.5.2)
bundler
rake
- arel (4.0.0)
- atomic (1.1.9)
- bcrypt-ruby (3.0.1)
+ arel (4.0.2)
+ atomic (1.1.15)
+ bcrypt (3.1.7)
+ bcrypt-ruby (3.1.5)
+ bcrypt (>= 3.1.3)
builder (3.1.4)
- i18n (0.6.4)
+ ffi (1.9.3)
+ ffi-compiler (0.1.3)
+ ffi (>= 1.0.0)
+ rake
+ i18n (0.6.9)
minitest (4.7.5)
- multi_json (1.7.7)
- rake (10.1.0)
- scrypt (1.1.0)
- sqlite3 (1.3.7)
- thread_safe (0.1.0)
- atomic
- timecop (0.6.1)
- tzinfo (0.3.37)
+ multi_json (1.8.4)
+ rake (10.1.1)
+ scrypt (1.2.0)
+ ffi-compiler (>= 0.0.2)
+ rake
+ sqlite3 (1.3.9)
+ thread_safe (0.2.0)
+ atomic (>= 1.1.7, < 2)
+ timecop (0.7.1)
+ tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
- activerecord (= 4.0.0)
- activesupport (= 4.0.0)
+ activerecord (= 4.0.3)
+ activesupport (= 4.0.3)
appraisal
authlogic!
bcrypt-ruby
View
30 lib/authlogic/session/cookies.rb
@@ -11,7 +11,7 @@ def self.included(klass)
after_destroy :destroy_cookie
end
end
-
+
# Configuration for the cookie feature set.
module Config
# The name of the cookie or the key in the cookies hash. Be sure and use a unique name. If you have multiple sessions and they use the same cookie it will cause problems.
@@ -19,7 +19,7 @@ module Config
#
# session = UserSession.new
# session.cookie_key => "user_credentials"
- #
+ #
# session = UserSession.new(:super_high_secret)
# session.cookie_key => "super_high_secret_user_credentials"
#
@@ -29,7 +29,7 @@ def cookie_key(value = nil)
rw_config(:cookie_key, value, "#{klass_name.underscore}_credentials")
end
alias_method :cookie_key=, :cookie_key
-
+
# If sessions should be remembered by default or not.
#
# * <tt>Default:</tt> false
@@ -38,7 +38,7 @@ def remember_me(value = nil)
rw_config(:remember_me, value, false)
end
alias_method :remember_me=, :remember_me
-
+
# The length of time until the cookie expires.
#
# * <tt>Default:</tt> 3.months
@@ -66,7 +66,7 @@ def httponly(value = nil)
end
alias_method :httponly=, :httponly
end
-
+
# The methods available for an Authlogic::Session::Base object that make up the cookie feature set.
module InstanceMethods
# Allows you to set the remember_me option when passing credentials.
@@ -81,29 +81,29 @@ def credentials=(value)
self.remember_me = r if !r.nil?
end
end
-
+
# 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
-
+
# Accepts a boolean as a flag to remember the session or not. Basically to expire the cookie at the end of the session or keep it for "remember_me_until".
def remember_me=(value)
@remember_me = value
end
-
+
# See remember_me
def remember_me?
remember_me == true || remember_me == "true" || remember_me == "1"
end
-
+
# How long to remember the user if remember_me is true. This is based on the class level configuration: remember_me_for
def remember_me_for
return unless remember_me?
self.class.remember_me_for
end
-
+
# When to expire the cookie. See remember_me_for configuration option to change this.
def remember_me_until
return unless remember_me?
@@ -152,11 +152,11 @@ def httponly?
def cookie_key
build_key(self.class.cookie_key)
end
-
+
def cookie_credentials
controller.cookies[cookie_key] && controller.cookies[cookie_key].split("::")
end
-
+
# Tries to validate the session from information in the cookie
def persist_by_cookie
persistence_token, record_id = cookie_credentials
@@ -168,9 +168,9 @@ def persist_by_cookie
false
end
end
-
+
def save_cookie
- remember_me_until_value = "::#{remember_me_until}" if remember_me?
+ remember_me_until_value = "::#{remember_me_until.iso8601}" if remember_me?
controller.cookies[cookie_key] = {
:value => "#{record.persistence_token}::#{record.send(record.class.primary_key)}#{remember_me_until_value}",
:expires => remember_me_until,
@@ -179,7 +179,7 @@ def save_cookie
:domain => controller.cookie_domain
}
end
-
+
def destroy_cookie
controller.cookies.delete cookie_key, :domain => controller.cookie_domain
end
View
2  test/session_test/cookies_test.rb
@@ -141,7 +141,7 @@ def test_after_save_save_cookie_with_remember_me
session = UserSession.new(ben)
session.remember_me = true
assert session.save
- assert_equal "#{ben.persistence_token}::#{ben.id}::#{session.remember_me_until}", controller.cookies["user_credentials"]
+ assert_equal "#{ben.persistence_token}::#{ben.id}::#{session.remember_me_until.iso8601}", controller.cookies["user_credentials"]
end
def test_after_destroy_destroy_cookie
Please sign in to comment.
Something went wrong with that request. Please try again.