lib/devise/models/confirmable.rb in loyal_devise-2.1.7 vs lib/devise/models/confirmable.rb in loyal_devise-2.1.10

- old
+ new

@@ -91,11 +91,11 @@ # Send confirmation instructions by email def send_confirmation_instructions self.confirmation_token = nil if reconfirmation_required? @reconfirmation_required = false - ensure_confirmation_token! + generate_confirmation_token! if self.confirmation_token.blank? opts = pending_reconfirmation? ? { :to => unconfirmed_email } : { } send_devise_notification(:confirmation_instructions, opts) end @@ -104,15 +104,10 @@ pending_any_confirmation do self.confirmation_token = nil if confirmation_period_expired? send_confirmation_instructions end end - - # Generate a confirmation token unless already exists and save the record. - def ensure_confirmation_token! - generate_confirmation_token! if should_generate_confirmation_token? - end # Overwrites active_for_authentication? for confirmation # by verifying whether a user is active to sign in or not. If the user # is already confirmed, it should never be blocked. Otherwise we need to # calculate if the confirm time has not expired for this user. @@ -142,13 +137,10 @@ def skip_reconfirmation! @bypass_postpone = true end protected - def should_generate_confirmation_token? - confirmation_token.nil? || confirmation_period_expired? - end # A callback method used to deliver confirmation # instructions on creation. This can be overriden # in models to map to a nice sign up e-mail. def send_on_create_confirmation_instructions @@ -233,20 +225,20 @@ self.unconfirmed_email = self.email self.email = self.email_was end def postpone_email_change? - postpone = self.class.reconfirmable && email_changed? && !@bypass_postpone && !self.email.blank? + postpone = self.class.reconfirmable && email_changed? && !@bypass_postpone @bypass_postpone = false postpone end def reconfirmation_required? - self.class.reconfirmable && @reconfirmation_required && !self.email.blank? + self.class.reconfirmable && @reconfirmation_required end def send_confirmation_notification? - confirmation_required? && !@skip_confirmation_notification && !self.email.blank? + confirmation_required? && !@skip_confirmation_notification end module ClassMethods # Attempt to find a user by its email. If a record is found, send new # confirmation instructions to it. If not, try searching for a user by unconfirmed_email