heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
23.89k stars 5.54k forks source link

Make sure Mailer defaults :from and :reply_to are handled correctly #5595

Closed louim closed 1 year ago

louim commented 1 year ago

Rails allow procs and lambda with either zero or more argument as values for the different defaults. Devise however always tried to call instance_eval on those values, which does always pass one argument: self.

There was a PR to fix this specific problem in Devise https://github.com/heartcombo/devise/pull/4627, before the arity check was fixed in rails itself: https://github.com/rails/rails/pull/30391.

But even if the problem was fixed in Rails, Devise was still calling the proc/lambas with instance_eval. That meant the fix added to Rails did not apply to Devise.

The fix is to let Rails handle the :from and :reply_to defaults. We do that by unsetting the corresponding headers instead of duplicate the way Rails handles callables in Devise. This lets Rails handle the values when setting up the mailer.