fix(users): don't expose email of accounts already confirmed

This commit is contained in:
Colin Darie 2024-07-29 11:40:27 +02:00
parent 7c51c38f15
commit a6554aa7bf
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
4 changed files with 37 additions and 3 deletions

View file

@ -13,9 +13,19 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
# end
# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end
def show
super do
# When email was already confirmed, default is to render :new with a specific error.
# Because our :new is customized with the email and a form to resend a confirmation,
# we redirect to after confirmation page instead.
if resource.errors.of_kind?(:email, :already_confirmed)
respond_with_navigational(resource) do
flash.notice = t('.email_already_confirmed')
redirect_to after_confirmation_path_for(resource_name, resource) and return
end
end
end
end
# protected