Fix email submission flow for suppliers

This commit is contained in:
2013-01-21 09:19:42 +01:00
parent 702bd41ee4
commit 4fd4fa3a85
3 changed files with 16 additions and 6 deletions
+11 -1
View File
@@ -97,11 +97,21 @@ class Supplier
# Overwrite devise method for mail sending
def self.confirm_by_token(confirmation_token)
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
send_creation_mail = confirmable.errors.empty? && !confirmable.confirmed?
confirmable.confirm! if confirmable.persisted?
confirmable.send_creation_notifications if confirmable.errors.empty?
confirmable.send_creation_notifications if send_creation_mail
confirmable
end
# Send confirmation instructions by email
def send_confirmation_instructions
self.confirmation_token = nil if reconfirmation_required?
@reconfirmation_required = false
@bypass_postpone = true and generate_confirmation_token! if self.confirmation_token.blank?
self.devise_mailer.confirmation_instructions(self).deliver
end
def send_creation_notifications
SupplierMailer.creation(self).deliver
end