diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 86085a4246..147f82e041 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1407,7 +1407,7 @@ def referral_programs end def referral_program_create - @referral_program = Referral::Program.new(name: params[:name], creator: current_user) + @referral_program = Referral::Program.new(name: params[:name], redirect_to: params[:redirect_to], creator: current_user) if @referral_program.save flash[:success] = "Referral program created successfully." diff --git a/app/controllers/referral/links_controller.rb b/app/controllers/referral/links_controller.rb index 5d886033fd..30ea6ea153 100644 --- a/app/controllers/referral/links_controller.rb +++ b/app/controllers/referral/links_controller.rb @@ -17,11 +17,13 @@ def show Rails.error.handle do Referral::Attribution.create!(user: current_user, program: @link.program, link: @link) end + + redirect_to @link.program.redirect_to.presence || root_path, allow_other_host: true else skip_authorization - end - redirect_to params[:return_to] || root_path + redirect_to params[:return_to] || root_path + end end private diff --git a/app/models/referral/program.rb b/app/models/referral/program.rb index 4362971937..f4a33b717d 100644 --- a/app/models/referral/program.rb +++ b/app/models/referral/program.rb @@ -10,6 +10,7 @@ # login_header_text :string # login_text_color :string # name :string not null +# redirect_to :string # created_at :datetime not null # updated_at :datetime not null # creator_id :bigint diff --git a/app/views/admin/referral_programs.html.erb b/app/views/admin/referral_programs.html.erb index 07ebd95794..cf9e84f46c 100644 --- a/app/views/admin/referral_programs.html.erb +++ b/app/views/admin/referral_programs.html.erb @@ -8,6 +8,7 @@