Do not rely on attribute? methods since they are not available in Datamapper.

This commit is contained in:
José Valim 2009-11-22 00:24:34 -02:00
parent 2f759f8d29
commit 3efc0ec08a
4 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,6 @@
* enhancements
* [#45] Do not rely attribute? methods, since they are not added on Datamapper
== 0.5.6 == 0.5.6
* enhancements * enhancements

2
TODO
View File

@ -1,3 +1,5 @@
* Create update_with_password
* Make test run with different ORMs
* Devise::Timeoutable * Devise::Timeoutable
* Use request_ip in session cookies * Use request_ip in session cookies
* Devise::BruteForceProtection * Devise::BruteForceProtection

View File

@ -51,7 +51,7 @@ module Devise
# Verifies whether a user is confirmed or not # Verifies whether a user is confirmed or not
def confirmed? def confirmed?
!new_record? && confirmed_at? !new_record? && !confirmed_at.nil?
end end
# Send confirmation instructions by email # Send confirmation instructions by email
@ -100,8 +100,8 @@ module Devise
# confirmation_period_valid? # will always return false # confirmation_period_valid? # will always return false
# #
def confirmation_period_valid? def confirmation_period_valid?
confirmation_sent_at? && confirmation_sent_at &&
(Time.now.utc - confirmation_sent_at.utc) < confirm_within ((Time.now.utc - confirmation_sent_at.utc) < confirm_within)
end end
# Checks whether the record is confirmed or not, yielding to the block # Checks whether the record is confirmed or not, yielding to the block

View File

@ -51,7 +51,7 @@ module Devise
# Removes the remember token only if it exists, and save the record # Removes the remember token only if it exists, and save the record
# without validations. # without validations.
def forget_me! def forget_me!
if remember_token? if remember_token
self.remember_token = nil self.remember_token = nil
self.remember_created_at = nil self.remember_created_at = nil
save(false) save(false)
@ -60,7 +60,7 @@ module Devise
# Checks whether the incoming token matches or not with the record token. # Checks whether the incoming token matches or not with the record token.
def valid_remember_token?(token) def valid_remember_token?(token)
remember_token? && !remember_expired? && remember_token == token remember_token && !remember_expired? && remember_token == token
end end
# Remember token should be expired if expiration time not overpass now. # Remember token should be expired if expiration time not overpass now.