From 6c03e258fa2393a30a628b2e2ecb7d47277bea54 Mon Sep 17 00:00:00 2001 From: Iraline Date: Mon, 18 Apr 2022 13:56:18 -0300 Subject: [PATCH] Added conditional to check if token has already been used --- app/controllers/users/confirmations_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index f615844c6..343f95f80 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -35,8 +35,15 @@ class Users::ConfirmationsController < Devise::ConfirmationsController respond_with_navigational(resource) { render :show } elsif resource.errors.empty? set_official_position if resource.has_official_email? - resource.confirm # Last change: confirm happens here for people with passwords instead of af the top of the show action - set_flash_message(:notice, :confirmed) if is_flashing_format? + + if resource.confirmed_at + message = :already_confirmed + else + resource.confirm # Last change: confirm happens here for people with passwords instead of af the top of the show action + message = :confirmed + end + + set_flash_message(:notice, message) if is_flashing_format? respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) } else respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }