Files
danbooru/app/controllers/password_resets_controller.rb
evazion 32613f9bb1 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.
2022-01-02 16:07:57 -06:00

26 lines
787 B
Ruby

# frozen_string_literal: true
class PasswordResetsController < ApplicationController
respond_to :html, :xml, :json
def create
@user = User.find_by_name(params.dig(:user, :name))
if @user.blank?
flash[:notice] = "That account does not exist"
redirect_to password_reset_path
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"
respond_with(@user, location: new_session_path)
else
flash[:notice] = "Password not reset. This account does not have a valid, verified email address"
respond_with(@user)
end
end
def show
end
end