feat(user): always allow devise mail
This commit is contained in:
parent
607fbf5287
commit
8104157da6
4 changed files with 17 additions and 5 deletions
|
@ -8,6 +8,10 @@ module BalancedDeliveryConcern
|
|||
self.class.critical_email?(action_name)
|
||||
end
|
||||
|
||||
def bypass_unverified_mail_protection!
|
||||
headers[BalancerDeliveryMethod::BYPASS_UNVERIFIED_MAIL_PROTECTION] = true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def forced_delivery_provider?
|
||||
|
|
|
@ -34,6 +34,8 @@ class DeviseUserMailer < Devise::Mailer
|
|||
@procedure = opts[:procedure_after_confirmation] || nil
|
||||
@prefill_token = opts[:prefill_token]
|
||||
|
||||
bypass_unverified_mail_protection!
|
||||
|
||||
I18n.with_locale(record.locale) do
|
||||
super
|
||||
end
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
RSpec.describe BalancerDeliveryMethod do
|
||||
class ExampleMailer < ApplicationMailer
|
||||
include BalancedDeliveryConcern
|
||||
|
||||
def greet(name, bypass_unverified_mail_protection: true)
|
||||
mail(to: name, from: "smtp_from", body: "Hello #{name}")
|
||||
|
||||
if bypass_unverified_mail_protection
|
||||
headers['BYPASS_UNVERIFIED_MAIL_PROTECTION'] = true
|
||||
end
|
||||
bypass_unverified_mail_protection! if bypass_unverified_mail_protection
|
||||
end
|
||||
end
|
||||
|
||||
class ImportantEmail < ApplicationMailer
|
||||
include BalancedDeliveryConcern
|
||||
|
||||
before_action :set_x_deliver_with
|
||||
|
||||
def greet(name)
|
||||
mail(to: name, from: "smtp_from", body: "Hello #{name}")
|
||||
headers['BYPASS_UNVERIFIED_MAIL_PROTECTION'] = true
|
||||
|
||||
bypass_unverified_mail_protection!
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,7 +5,10 @@ RSpec.describe DeviseUserMailer, type: :mailer do
|
|||
subject { described_class.confirmation_instructions(user, token, opts = {}) }
|
||||
|
||||
context 'without SafeMailer configured' do
|
||||
it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) }
|
||||
it do
|
||||
expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil)
|
||||
expect(subject[BalancerDeliveryMethod::BYPASS_UNVERIFIED_MAIL_PROTECTION]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'with SafeMailer configured' do
|
||||
|
|
Loading…
Reference in a new issue