You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

  1. # frozen_string_literal: true
  2. class UserMailer < Devise::Mailer
  3. layout 'mailer'
  4. helper :instance
  5. def confirmation_instructions(user, token, **)
  6. @resource = user
  7. @token = token
  8. @instance = Rails.configuration.x.local_domain
  9. return if @resource.disabled?
  10. I18n.with_locale(@resource.locale || I18n.default_locale) do
  11. mail to: @resource.unconfirmed_email.blank? ? @resource.email : @resource.unconfirmed_email,
  12. subject: I18n.t(@resource.pending_reconfirmation? ? 'devise.mailer.reconfirmation_instructions.subject' : 'devise.mailer.confirmation_instructions.subject', instance: @instance),
  13. template_name: @resource.pending_reconfirmation? ? 'reconfirmation_instructions' : 'confirmation_instructions'
  14. end
  15. end
  16. def reset_password_instructions(user, token, **)
  17. @resource = user
  18. @token = token
  19. @instance = Rails.configuration.x.local_domain
  20. return if @resource.disabled?
  21. I18n.with_locale(@resource.locale || I18n.default_locale) do
  22. mail to: @resource.email, subject: I18n.t('devise.mailer.reset_password_instructions.subject')
  23. end
  24. end
  25. def password_change(user, **)
  26. @resource = user
  27. @instance = Rails.configuration.x.local_domain
  28. return if @resource.disabled?
  29. I18n.with_locale(@resource.locale || I18n.default_locale) do
  30. mail to: @resource.email, subject: I18n.t('devise.mailer.password_change.subject')
  31. end
  32. end
  33. def email_changed(user, **)
  34. @resource = user
  35. @instance = Rails.configuration.x.local_domain
  36. return if @resource.disabled?
  37. I18n.with_locale(@resource.locale || I18n.default_locale) do
  38. mail to: @resource.email, subject: I18n.t('devise.mailer.email_changed.subject')
  39. end
  40. end
  41. end