diff --git a/app/create.rb b/app/create.rb index d2f3b1e6..00061f74 100644 --- a/app/create.rb +++ b/app/create.rb @@ -104,6 +104,10 @@ post '/create' do return {result: 'error'}.to_json end + if defined?(BlackBox.tutorial_required?) && BlackBox.tutorial_required?(@site, request) + @site.tutorial_required = true + end + if !@site.valid? flash[:error] = @site.errors.first.last.first return {result: 'error'}.to_json diff --git a/app/tutorial.rb b/app/tutorial.rb index 2ffe69bd..582308ec 100644 --- a/app/tutorial.rb +++ b/app/tutorial.rb @@ -38,5 +38,15 @@ get '/tutorial/:section/:page/?' do @title = "#{params[:section].upcase} Tutorial - #{@page}/10" + + if @page == '9' + unless csrf_safe? + signout + redirect '/' + end + current_site.tutorial_required = false + current_site.save_changes validate: false + end + erb "tutorial/layout".to_sym end diff --git a/app_helpers.rb b/app_helpers.rb index ee6b2928..df0d4991 100644 --- a/app_helpers.rb +++ b/app_helpers.rb @@ -16,6 +16,7 @@ end def require_login redirect '/' unless signed_in? && current_site + redirect '/tutorial/html/1' if current_site.tutorial_required && !(request.path =~ /tutorial/) end def signed_in? diff --git a/migrations/124_sites_tutorial_required.rb b/migrations/124_sites_tutorial_required.rb new file mode 100644 index 00000000..d9003e85 --- /dev/null +++ b/migrations/124_sites_tutorial_required.rb @@ -0,0 +1,9 @@ +Sequel.migration do + up { + DB.add_column :sites, :tutorial_required, :boolean, default: false + } + + down { + DB.drop_column :sites, :tutorial_required + } +end \ No newline at end of file diff --git a/views/_header.erb b/views/_header.erb index 32795919..f6d0c78b 100644 --- a/views/_header.erb +++ b/views/_header.erb @@ -41,7 +41,9 @@
<% end %> -