diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index 9a281df16..e4a21675b 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -4,6 +4,7 @@ class Auth::PasswordsController < Devise::PasswordsController def reset_confirmation self.resource = resource_class.new @email = params["email"] + @unconfirmed = params["unconfirmed"] == "true" if @email.blank? resource.errors.add :email, I18n.t("validations.email.blank") render "devise/passwords/new", status: :unprocessable_entity @@ -65,8 +66,8 @@ protected resource.need_two_factor_authentication?(request) ? :updated_2FA : :updated end - def after_sending_reset_password_instructions_path_for(_resource) - account_password_reset_confirmation_path(email: params.dig("user", "email")) + def after_sending_reset_password_instructions_path_for(_resource_name) + account_password_reset_confirmation_path(email: params.dig("user", "email"), unconfirmed: resource.initial_confirmation_sent && !resource.confirmed?) end def after_resetting_password_path_for(resource) diff --git a/app/models/user.rb b/app/models/user.rb index b504db9bc..23dbc196b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -358,6 +358,14 @@ class User < ApplicationRecord end end + def send_reset_password_instructions + if confirmed? + super + else + send_confirmation_instructions + end + end + protected # Checks whether a password is needed or not. For validations only. diff --git a/app/views/devise/passwords/reset_resend_confirmation.html.erb b/app/views/devise/passwords/reset_resend_confirmation.html.erb index b89717844..106f4d87e 100644 --- a/app/views/devise/passwords/reset_resend_confirmation.html.erb +++ b/app/views/devise/passwords/reset_resend_confirmation.html.erb @@ -6,7 +6,11 @@ <%= content_for(:title) %> -

We’ve sent a link to reset your password to <%= @email %>.

+ <% if @unconfirmed %> +

We’ve sent a link to confirm your email address to <%= @email %>. This will complete your registration onto the CORE service.

+ <% else %> +

We’ve sent a link to reset your password to <%= @email %>.

+ <% end %>

You’ll only receive this link if your email address already exists in our system.

If you don’t receive the email within 5 minutes, check your spam or junk folders. Try again if you still haven’t received the email.