heartcombo / devise

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

How to prevent to send a confirmation email when email field is updated ? #903 #5671

Closed adrys-lab closed 9 months ago

adrys-lab commented 9 months ago

Environment

In our application we are sending a confirmation email (OLD email, saying email has changed, NEW email confirm your email) when a user updates his email.

Now this is handled by another system and we want the legacy service stop sending such notification (NEW email confirm your email),

is there a standalone configuration to prevent that ?

Could it be this option ?

config.reconfirmable = true We want ONLY avoid sending emails when email update (meaning from xx@xx.com to yy@yy.com),

but keep sending emails on NEW SIGN IN.

i would like to find a proper configuration that allows us to do so, instead of hijacking it like the snipped code below:

  def confirmation_instructions(record, token, opts = {})
    return if opts[:action] == "email_update"

    XXXX
  end
carlosantoniodasilva commented 9 months ago

I think you're looking for skip_confirmation_notification! before you update the user attributes with the new email.

Note that they'll still require the new email to be confirmed, just won't get the email notification. If you don't want that, you can maybe use skip_reconfirmation!, or maybe just disable the entire reconfirmable feature like you mentioned.