diff --git a/app/controllers/email_confirmations_controller.rb b/app/controllers/email_confirmations_controller.rb index 6671553..96dc96b 100644 --- a/app/controllers/email_confirmations_controller.rb +++ b/app/controllers/email_confirmations_controller.rb @@ -1,5 +1,19 @@ class EmailConfirmationsController < ApplicationController - allow_unauthenticated_access only: :show + allow_unauthenticated_access only: %i[ new create show ] + rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_email_confirmation_path, alert: "Try again later." } + + def new + end + + def create + user = User.find_by(email_address: params[:email_address]) + + if user && !user.confirmed? + RegistrationMailer.confirmation(user, Current.organization).deliver_later + end + + redirect_to new_session_path, notice: "Confirmation instructions sent (if an unconfirmed account with that email address exists)." + end def show if user = User.find_by_token_for(:email_confirmation, params[:token]) diff --git a/app/views/email_confirmations/new.html.erb b/app/views/email_confirmations/new.html.erb new file mode 100644 index 0000000..890d1f6 --- /dev/null +++ b/app/views/email_confirmations/new.html.erb @@ -0,0 +1,15 @@ +