emails: fix sending emails to invalid addresses.

Fix mailers to not attempt deliveries to invalid or nonexistent email
addresses. This usually happened when someone changed their email, and
we tried to send a confirmation email to a nonexistent address.
This commit is contained in:
evazion
2022-01-02 12:23:01 -06:00
parent 9ffc269e43
commit 32613f9bb1
8 changed files with 30 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ class PasswordResetsController < ApplicationController
if @user.blank?
flash[:notice] = "That account does not exist"
redirect_to password_reset_path
elsif @user.can_receive_email?(require_verification: false)
elsif @user.can_receive_email?(require_verified_email: false)
UserMailer.password_reset(@user).deliver_later
UserEvent.create_from_request!(@user, :password_reset, request)
flash[:notice] = "Password reset email sent. Check your email"

View File

@@ -90,7 +90,7 @@ class UsersController < ApplicationController
flash[:notice] = "Sign up failed: #{@user.errors.full_messages.join("; ")}"
else
session[:user_id] = @user.id
UserMailer.welcome_user(@user).deliver_later if @user.can_receive_email?(require_verification: false)
UserMailer.welcome_user(@user).deliver_later
set_current_user
end