From cc0115eb3a3e9730a6b281b0afa88cac91132f0b Mon Sep 17 00:00:00 2001 From: Godwin Date: Tue, 2 Aug 2016 17:44:10 -0700 Subject: [PATCH] Added confirmation emails for unregisterd users when adding facilitators or companions --- app/controllers/conferences_controller.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 8efbfdb..d96418a 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -636,6 +636,9 @@ class ConferencesController < ApplicationController notes: params[:notes] } when :questions + # create the companion's user account and send a registration link unless they have already registered + generate_confirmation(User.create(email: params[:companion]), register_path(@this_conference.slug)) unless User.find_by_email(params[:companion]) + @registration.housing = params[:housing] @registration.arrival = params[:arrival] @registration.departure = params[:departure] @@ -1664,10 +1667,17 @@ class ConferencesController < ApplicationController end def add_workshop_facilitator - user = User.find_by_email(params[:email]) || User.create(email: params[:email]) - set_conference set_conference_registration! + + user = User.find_by_email(params[:email]) + + # create the user if they don't exist and send them a link to register + unless user + user = User.create(email: params[:email]) + generate_confirmation(user, register_path(@this_conference.slug)) + end + workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id) return do_404 unless workshop && current_user