diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c6f634d6..f00f26d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base include ActiveStorage::SetCurrent include Pagy::Backend + before_action :sign_in_for_demo, if: -> { Docuseal.demo? } before_action :maybe_redirect_to_setup, unless: :signed_in? before_action :authenticate_user!, unless: :devise_controller? @@ -21,6 +22,10 @@ class ApplicationController < ActionController::Base private + def sign_in_for_demo + sign_in(User.first) unless signed_in? + end + def current_account current_user&.account end diff --git a/lib/docuseal.rb b/lib/docuseal.rb index ea3793f3..89e2b4e6 100644 --- a/lib/docuseal.rb +++ b/lib/docuseal.rb @@ -23,6 +23,10 @@ module Docuseal ENV['MULTITENANT'] == 'true' end + def demo? + ENV['DEMO'] == 'true' + end + def active_storage_public? ENV['ACTIVE_STORAGE_PUBLIC'] == 'true' end