lib/devise/models/lockable.rb in devise-3.0.0.rc vs lib/devise/models/lockable.rb in devise-3.0.0

- old
+ new

@@ -53,11 +53,11 @@ save(:validate => false) end # Verifies whether a user is locked or not. def access_locked? - locked_at && !lock_expired? + !!locked_at && !lock_expired? end # Send unlock instructions by email def send_unlock_instructions send_devise_notification(:unlock_instructions) @@ -144,19 +144,19 @@ # if it's locked, otherwise adds an error to email. def if_access_locked if access_locked? yield else - self.errors.add(:email, :not_locked) + self.errors.add(Devise.unlock_keys.first, :not_locked) false end end module ClassMethods - # Attempt to find a user by its email. If a record is found, send new + # Attempt to find a user by its unlock keys. If a record is found, send new # unlock instructions to it. If not user is found, returns a new user # with an email not found error. - # Options must contain the user email + # Options must contain the user's unlock keys def send_unlock_instructions(attributes={}) lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found) lockable.resend_unlock_token if lockable.persisted? lockable end