renamed confirmation_on_email_change property to reconfirmable and added reconfirmable explanations

This commit is contained in:
mandaryn 2011-04-17 12:15:35 +02:00 committed by Brian Rose
parent 1961de6b5d
commit 6469cbc62a
6 changed files with 20 additions and 10 deletions

View File

@ -139,8 +139,8 @@ module Devise
mattr_accessor :confirmation_keys
@@confirmation_keys = [ :email ]
mattr_accessor :confirmation_on_email_change
@@confirmation_on_email_change = false
mattr_accessor :reconfirmable
@@reconfirmable = false
# Time interval to timeout the user session without activity.
mattr_accessor :timeout_in

View File

@ -14,6 +14,10 @@ module Devise
# use this to let your user access some features of your application without
# confirming the account, but blocking it after a certain period (ie 7 days).
# By default confirm_within is zero, it means users always have to confirm to sign in.
# * +reconfirmable+: requires any email changes to be confirmed (exctly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field to be setup (see migrations). Until confirmed new email is stored in
# unconfirmed email column, and copied to email column on successful confirmation.
#
# == Examples
#
@ -144,11 +148,11 @@ module Devise
end
def prevent_email_change?
self.class.confirmation_on_email_change && email_changed? && email != unconfirmed_email_was
self.class.reconfirmable && email_changed? && email != unconfirmed_email_was
end
def email_change_confirmation_required?
self.class.confirmation_on_email_change && @email_change_confirmation_required
self.class.reconfirmable && @email_change_confirmation_required
end
module ClassMethods
@ -186,7 +190,7 @@ module Devise
find_or_initialize_with_errors(confirmation_keys_with_replaced_email, attributes, :not_found)
end
Devise::Models.config(self, :confirm_within, :confirmation_keys, :confirmation_on_email_change)
Devise::Models.config(self, :confirm_within, :confirmation_keys, :reconfirmable)
end
end
end

View File

@ -38,7 +38,7 @@ module Devise
apply_devise_schema :confirmation_token, String
apply_devise_schema :confirmed_at, DateTime
apply_devise_schema :confirmation_sent_at, DateTime
apply_devise_schema :unconfirmed_email, String
apply_devise_schema :unconfirmed_email, String
end
# Creates reset_password_token and reset_password_sent_at.

View File

@ -80,6 +80,12 @@ Devise.setup do |config|
# (ie 2 days).
# config.confirm_within = 2.days
# If true, requires any email changes to be confirmed (exctly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed new email is stored in
# unconfirmed email column, and copied to email column on successful confirmation.
# config.reconfirmable = false
# Defines which key will be used when confirming an account
# config.confirmation_keys = [ :email ]

View File

@ -180,11 +180,11 @@ end
class ConfirmationOnChangeTest < ConfirmationTest
def setup
Devise.confirmation_on_email_change = true
Devise.reconfirmable = true
end
def teardown
Devise.confirmation_on_email_change = false
Devise.reconfirmable = false
end
test 'user should be able to request a new confirmation after email changed' do

View File

@ -239,11 +239,11 @@ end
class ConfirmableOnChangeTest < ConfirmableTest
def setup
Devise.confirmation_on_email_change = true
Devise.reconfirmable = true
end
def teardown
Devise.confirmation_on_email_change = false
Devise.reconfirmable = false
end
def test_should_not_resend_email_instructions_if_the_user_change_his_email