From 62ee016c7c57429b78e1acd2d7c5b382bef53053 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 9 Apr 2019 19:11:09 +1000 Subject: [PATCH] ensure wizard exists before forcing redirect --- lib/wizard.rb | 4 ++++ plugin.rb | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/wizard.rb b/lib/wizard.rb index 734ea0d4..e98b933a 100644 --- a/lib/wizard.rb +++ b/lib/wizard.rb @@ -182,6 +182,10 @@ class CustomWizard::Wizard PluginStore.get('custom_wizard', wizard_id) end + def self.exists?(wizard_id) + PluginStoreRow.exists?(plugin_name: 'custom_wizard', key: wizard_id) + end + def self.create(user, wizard_id) CustomWizard::Wizard.new(user, self.find(wizard_id).to_h) end diff --git a/plugin.rb b/plugin.rb index c702d542..231bb7e1 100644 --- a/plugin.rb +++ b/plugin.rb @@ -128,7 +128,9 @@ after_initialize do CustomWizard::Wizard.set_submission_redirect(current_user, wizard_id, request.referer) end - redirect_to "/w/#{wizard_id.dasherize}" + if CustomWizard::Wizard.exists?(wizard_id) + redirect_to "/w/#{wizard_id.dasherize}" + end end end end