From 82cb2668bc154b98f972133267299681e7ac5f6e Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 8 Oct 2019 16:46:13 +1100 Subject: [PATCH] add guest login --- assets/javascripts/wizard-custom-guest.js | 3 +++ controllers/wizard.rb | 6 ++++++ views/layouts/wizard.html.erb | 8 ++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 assets/javascripts/wizard-custom-guest.js diff --git a/assets/javascripts/wizard-custom-guest.js b/assets/javascripts/wizard-custom-guest.js new file mode 100644 index 00000000..38a526d5 --- /dev/null +++ b/assets/javascripts/wizard-custom-guest.js @@ -0,0 +1,3 @@ +(function() { + window.location.href = "/login"; +})(); diff --git a/controllers/wizard.rb b/controllers/wizard.rb index e2d5656f..2d384530 100644 --- a/controllers/wizard.rb +++ b/controllers/wizard.rb @@ -4,6 +4,12 @@ class CustomWizard::WizardController < ::ApplicationController helper_method :wizard_page_title helper_method :theme_ids + + before_action :handle_login_redirect, unless: :current_user + + def handle_login_redirect + cookies[:destination_url] = "/w/#{params[:wizard_id]}" + end def wizard CustomWizard::Template.new(PluginStore.get('custom_wizard', params[:wizard_id].underscore)) diff --git a/views/layouts/wizard.html.erb b/views/layouts/wizard.html.erb index 251d13ed..db15672b 100644 --- a/views/layouts/wizard.html.erb +++ b/views/layouts/wizard.html.erb @@ -40,8 +40,12 @@ <%= raw theme_lookup("body_tag") %> <%- end %> - <%= preload_script 'wizard-custom-start' %> - <%= preload_script 'wizard-raw-templates' %> + <%- if current_user %> + <%= preload_script 'wizard-custom-start' %> + <%= preload_script 'wizard-raw-templates' %> + <%- else %> + <%= preload_script 'wizard-custom-guest' %> + <%- end %>