diff --git a/Gemfile b/Gemfile index cb16e8ecc..e7ec18512 100644 --- a/Gemfile +++ b/Gemfile @@ -100,7 +100,9 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem "graphql", "~> 2.0" gem 'graphiql-rails' -gem "ember-cli-rails", "0.10.0" +if ENV["EMBER_ENABLED"] + gem "ember-cli-rails", "0.10.0" +end # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' gem "exception_notification", "~> 4.5" diff --git a/app/controllers/ember_cli/ember_controller.rb b/app/controllers/ember_cli/ember_controller.rb index 5c98dbe4e..cde4325c3 100644 --- a/app/controllers/ember_cli/ember_controller.rb +++ b/app/controllers/ember_cli/ember_controller.rb @@ -24,4 +24,4 @@ def redirect_if_unsupported end end end -end \ No newline at end of file +end diff --git a/ci_env.cfg b/ci_env.cfg index 4a4a128c1..d57142916 100644 --- a/ci_env.cfg +++ b/ci_env.cfg @@ -5,3 +5,4 @@ DATABASE_PASSWORD=password DATABASE_NAME=r_solutions_test DATABASE_PORT=5432 APP_HOST=restarone.com +EMBER_ENABLED=true diff --git a/config/initializers/active_job.rb b/config/initializers/active_job.rb index 11f25d86e..db1dd0b77 100644 --- a/config/initializers/active_job.rb +++ b/config/initializers/active_job.rb @@ -1,3 +1,6 @@ -class ActiveJob::Base - include Apartment::ActiveJob + +Rails.application.reloader.to_prepare do + class ActiveJob::Base + include Apartment::ActiveJob + end end \ No newline at end of file diff --git a/config/initializers/active_storge.rb b/config/initializers/active_storge.rb index 6a16813d7..4935e5271 100644 --- a/config/initializers/active_storge.rb +++ b/config/initializers/active_storge.rb @@ -1,13 +1,15 @@ -if Rails.env == 'production' || Rails.env == 'test' - require 'active_storage/attachment' +Rails.application.reloader.to_prepare do + if Rails.env == 'production' || Rails.env == 'test' + require 'active_storage/attachment' - class ActiveStorage::Attachment - before_save :ensure_storage_limit_not_exceeded + class ActiveStorage::Attachment + before_save :ensure_storage_limit_not_exceeded - def ensure_storage_limit_not_exceeded - unless Subdomain.current.has_enough_storage? - errors.add(:subdomain, 'out of storage') - throw(:abort) + def ensure_storage_limit_not_exceeded + unless Subdomain.current.has_enough_storage? + errors.add(:subdomain, 'out of storage') + throw(:abort) + end end end end diff --git a/config/initializers/ahoy.rb b/config/initializers/ahoy.rb index 787a9397a..fdb6ad648 100755 --- a/config/initializers/ahoy.rb +++ b/config/initializers/ahoy.rb @@ -1,11 +1,13 @@ -class Ahoy::Store < Ahoy::DatabaseStore -end +Rails.application.reloader.to_prepare do + class Ahoy::Store < Ahoy::DatabaseStore + end -# set to true for JavaScript tracking -Ahoy.api = false + # set to true for JavaScript tracking + Ahoy.api = false -# set to true for geocoding -# we recommend configuring local geocoding first -# see https://github.com/ankane/ahoy#geocoding -Ahoy.geocode = true -Ahoy.job_queue = :default + # set to true for geocoding + # we recommend configuring local geocoding first + # see https://github.com/ankane/ahoy#geocoding + Ahoy.geocode = true + Ahoy.job_queue = :default +end diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index da478c3f9..97eb9d11b 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -13,116 +13,121 @@ # # Apartment Configuration # -Apartment.configure do |config| - # Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace. - # A typical example would be a Customer or Tenant model that stores each Tenant's information. - # - config.excluded_models = %w{ Subdomain SubdomainRequest} +Rails.application.reloader.to_prepare do + Apartment.configure do |config| + # Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace. + # A typical example would be a Customer or Tenant model that stores each Tenant's information. + # + config.excluded_models = %w{ Subdomain SubdomainRequest} - # In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment. - # You can make this dynamic by providing a Proc object to be called on migrations. - # This object should yield either: - # - an array of strings representing each Tenant name. - # - a hash which keys are tenant names, and values custom db config - # (must contain all key/values required in database.yml) - # - # config.tenant_names = lambda{ Subdomain.pluck(:name) } - # config.tenant_names = ['tenant1', 'tenant2'] - # config.tenant_names = { - # 'tenant1' => { - # adapter: 'postgresql', - # host: 'some_server', - # port: 5555, - # database: 'postgres' # this is not the name of the tenant's db - # # but the name of the database to connect to before creating the tenant's db - # # mandatory in postgresql - # }, - # 'tenant2' => { - # adapter: 'postgresql', - # database: 'postgres' # this is not the name of the tenant's db - # # but the name of the database to connect to before creating the tenant's db - # # mandatory in postgresql - # } - # } - # config.tenant_names = lambda do - # Tenant.all.each_with_object({}) do |tenant, hash| - # hash[tenant.name] = tenant.db_configuration - # end - # end - # - config.tenant_names = lambda do - Subdomain.all.each_with_object({}) do |subdomain, hash| - hash[subdomain.name] = subdomain.db_configuration + # In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment. + # You can make this dynamic by providing a Proc object to be called on migrations. + # This object should yield either: + # - an array of strings representing each Tenant name. + # - a hash which keys are tenant names, and values custom db config + # (must contain all key/values required in database.yml) + # + # config.tenant_names = lambda{ Subdomain.pluck(:name) } + # config.tenant_names = ['tenant1', 'tenant2'] + # config.tenant_names = { + # 'tenant1' => { + # adapter: 'postgresql', + # host: 'some_server', + # port: 5555, + # database: 'postgres' # this is not the name of the tenant's db + # # but the name of the database to connect to before creating the tenant's db + # # mandatory in postgresql + # }, + # 'tenant2' => { + # adapter: 'postgresql', + # database: 'postgres' # this is not the name of the tenant's db + # # but the name of the database to connect to before creating the tenant's db + # # mandatory in postgresql + # } + # } + # config.tenant_names = lambda do + # Tenant.all.each_with_object({}) do |tenant, hash| + # hash[tenant.name] = tenant.db_configuration + # end + # end + # + config.tenant_names = lambda do + Subdomain.all.each_with_object({}) do |subdomain, hash| + hash[subdomain.name] = subdomain.db_configuration + end end - end - # PostgreSQL: - # Specifies whether to use PostgreSQL schemas or create a new database per Tenant. - # - # MySQL: - # Specifies whether to switch databases by using `use` statement or re-establish connection. - # - # The default behaviour is true. - # - # config.use_schemas = true + # PostgreSQL: + # Specifies whether to use PostgreSQL schemas or create a new database per Tenant. + # + # MySQL: + # Specifies whether to switch databases by using `use` statement or re-establish connection. + # + # The default behaviour is true. + # + # config.use_schemas = true - # - # ==> PostgreSQL only options + # + # ==> PostgreSQL only options - # Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas. - # Use this when you are using some extra features in PostgreSQL that can't be represented in - # schema.rb, like materialized views etc. (only applies with use_schemas set to true). - # (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump) - # - # config.use_sql = false + # Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas. + # Use this when you are using some extra features in PostgreSQL that can't be represented in + # schema.rb, like materialized views etc. (only applies with use_schemas set to true). + # (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump) + # + # config.use_sql = false - # There are cases where you might want some schemas to always be in your search_path - # e.g when using a PostgreSQL extension like hstore. - # Any schemas added here will be available along with your selected Tenant. - # - # config.persistent_schemas = %w{ hstore } + # There are cases where you might want some schemas to always be in your search_path + # e.g when using a PostgreSQL extension like hstore. + # Any schemas added here will be available along with your selected Tenant. + # + # config.persistent_schemas = %w{ hstore } - # <== PostgreSQL only options - # + # <== PostgreSQL only options + # - # By default, and only when not using PostgreSQL schemas, Apartment will prepend the environment - # to the tenant name to ensure there is no conflict between your environments. - # This is mainly for the benefit of your development and test environments. - # Uncomment the line below if you want to disable this behaviour in production. - # - # config.prepend_environment = !Rails.env.production? + # By default, and only when not using PostgreSQL schemas, Apartment will prepend the environment + # to the tenant name to ensure there is no conflict between your environments. + # This is mainly for the benefit of your development and test environments. + # Uncomment the line below if you want to disable this behaviour in production. + # + # config.prepend_environment = !Rails.env.production? - # When using PostgreSQL schemas, the database dump will be namespaced, and - # apartment will substitute the default namespace (usually public) with the - # name of the new tenant when creating a new tenant. Some items must maintain - # a reference to the default namespace (ie public) - for instance, a default - # uuid generation. Uncomment the line below to create a list of namespaced - # items in the schema dump that should *not* have their namespace replaced by - # the new tenant - # - config.pg_excluded_names = ["uuid_generate_v4"] + # When using PostgreSQL schemas, the database dump will be namespaced, and + # apartment will substitute the default namespace (usually public) with the + # name of the new tenant when creating a new tenant. Some items must maintain + # a reference to the default namespace (ie public) - for instance, a default + # uuid generation. Uncomment the line below to create a list of namespaced + # items in the schema dump that should *not* have their namespace replaced by + # the new tenant + # + config.pg_excluded_names = ["uuid_generate_v4"] - # Specifies whether the database and schema (when using PostgreSQL schemas) will prepend in ActiveRecord log. - # Uncomment the line below if you want to enable this behavior. - # - # config.active_record_log = true + # Specifies whether the database and schema (when using PostgreSQL schemas) will prepend in ActiveRecord log. + # Uncomment the line below if you want to enable this behavior. + # + # config.active_record_log = true + end end + # Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that + # you want to switch to. + # Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request| + # "www" + # } -# Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that -# you want to switch to. -# Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request| -# "www" -# } + # Rails.application.config.middleware.use Apartment::Elevators::Domain -# Rails.application.config.middleware.use Apartment::Elevators::Domain Rails.application.config.middleware.use Apartment::Elevators::Generic, Proc.new { |request| hostname = request.host.split('.')[0] Apartment.tenant_names.include?(hostname) ? hostname : 'public' } -# Rails.application.config.middleware.use Apartment::Elevators::Subdomain + + # Rails.application.config.middleware.use Apartment::Elevators::Subdomain # plug in exclusions model here -Apartment::Elevators::Subdomain.excluded_subdomains = [] +Rails.application.reloader.to_prepare do + Apartment::Elevators::Subdomain.excluded_subdomains = [] +end # Rails.application.config.middleware.use Apartment::Elevators::FirstSubdomain # Rails.application.config.middleware.use Apartment::Elevators::Host diff --git a/config/initializers/comfortable_mexican_sofa.rb b/config/initializers/comfortable_mexican_sofa.rb index d989b070b..ea8c40a42 100644 --- a/config/initializers/comfortable_mexican_sofa.rb +++ b/config/initializers/comfortable_mexican_sofa.rb @@ -1,188 +1,197 @@ # frozen_string_literal: true -module RSolutions::DeviseAuth - def authenticate - if current_user && current_user.can_access_admin - return true - else - flash.alert = "You do not have the permission to do that. Only users who can_access_admin are allowed to perform that action." - redirect_to root_url(subdomain: Apartment::Tenant.current) +Rails.application.reloader.to_prepare do + module RSolutions::DeviseAuth + def authenticate + if current_user && current_user.can_access_admin + return true + else + flash.alert = "You do not have the permission to do that. Only users who can_access_admin are allowed to perform that action." + redirect_to root_url(subdomain: Apartment::Tenant.current) + end end end end -module ComfyPublicAuthentication - def authenticate - if Subdomain.current.tracking_enabled - user_id = current_user ? current_user.id : nil - visit_id = current_visit ? current_visit.id : nil - ahoy.track( - "comfy-cms-page-visit", - { visit_id: visit_id, page_id: @cms_page&.id, user_id: user_id } - ) - end - protected_paths = Comfy::Cms::Page.where(is_restricted: true).pluck(:full_path) - return unless protected_paths.member?(@cms_page.full_path) - if current_user - if current_user.can_view_restricted_pages - return true +Rails.application.reloader.to_prepare do + module ComfyPublicAuthentication + def authenticate + if Subdomain.current.tracking_enabled + user_id = current_user ? current_user.id : nil + visit_id = current_visit ? current_visit.id : nil + ahoy.track( + "comfy-cms-page-visit", + { visit_id: visit_id, page_id: @cms_page&.id, user_id: user_id } + ) + end + protected_paths = Comfy::Cms::Page.where(is_restricted: true).pluck(:full_path) + return unless protected_paths.member?(@cms_page.full_path) + if current_user + if current_user.can_view_restricted_pages + return true + else + flash.alert = "You do not have the permission to do that. Only users who can_view_restricted_pages are allowed to perform that action." + redirect_to root_path + end else - flash.alert = "You do not have the permission to do that. Only users who can_view_restricted_pages are allowed to perform that action." - redirect_to root_path + flash.alert = "Please login first to view that page" + redirect_to new_user_session_path end - else - flash.alert = "Please login first to view that page" - redirect_to new_user_session_path end end end -module RSolutions::ComfyAdminAuthorization +Rails.application.reloader.to_prepare do + module RSolutions::ComfyAdminAuthorization - def perform_default_lockout - if (self.class.name == "Comfy::Admin::Cms::SitesController") - redirect_back(fallback_location: root_url) - else - return true + def perform_default_lockout + if (self.class.name == "Comfy::Admin::Cms::SitesController") + redirect_back(fallback_location: root_url) + else + return true + end end - end - def ensure_webmaster - if (!current_user.can_manage_web) - flash.alert = "You do not have the permission to do that. Only users who can_manage_web are allowed to perform that action." - redirect_back(fallback_location: root_url) - else - return true + def ensure_webmaster + if (!current_user.can_manage_web) + flash.alert = "You do not have the permission to do that. Only users who can_manage_web are allowed to perform that action." + redirect_back(fallback_location: root_url) + else + return true + end end - end - def ensure_blogmaster - if (!current_user.can_manage_blog) - flash.alert = "You do not have the permission to do that. Only users who can_manage_blog are allowed to perform that action." - redirect_back(fallback_location: root_url) - else - return true + def ensure_blogmaster + if (!current_user.can_manage_blog) + flash.alert = "You do not have the permission to do that. Only users who can_manage_blog are allowed to perform that action." + redirect_back(fallback_location: root_url) + else + return true + end end - end - def enforce_web_authorization - restricted_actions = [ - :new, - :create, - :edit, - :show, - :update, - :destroy, - ] - restricted_controllers = ['pages', 'layouts', 'snippets'] - - if (restricted_controllers.include?(controller_name)) && restricted_actions.include?(action_name.to_sym) - ensure_webmaster + def enforce_web_authorization + restricted_actions = [ + :new, + :create, + :edit, + :show, + :update, + :destroy, + ] + restricted_controllers = ['pages', 'layouts', 'snippets'] + + if (restricted_controllers.include?(controller_name)) && restricted_actions.include?(action_name.to_sym) + ensure_webmaster + end end - end - def enforce_blog_authorization - if controller_name == 'posts' - ensure_blogmaster + def enforce_blog_authorization + if controller_name == 'posts' + ensure_blogmaster + end end - end - def authorize - perform_default_lockout - enforce_web_authorization - enforce_blog_authorization + def authorize + perform_default_lockout + enforce_web_authorization + enforce_blog_authorization + end end end -ComfortableMexicanSofa.configure do |config| - # Title of the admin area - config.cms_title = "Violet WebAdmin" - # Controller that is inherited from CmsAdmin::BaseController - config.admin_base_controller = 'Subdomains::BaseController' +Rails.application.reloader.to_prepare do + ComfortableMexicanSofa.configure do |config| + # Title of the admin area + config.cms_title = "Violet WebAdmin" + + # Controller that is inherited from CmsAdmin::BaseController + config.admin_base_controller = 'Subdomains::BaseController' - # Controller that Comfy::Cms::BaseController will inherit from + # Controller that Comfy::Cms::BaseController will inherit from - config.public_base_controller = 'ContentController' + config.public_base_controller = 'ContentController' - config.admin_auth = 'RSolutions::DeviseAuth' - # Module responsible for authentication. You can replace it with your own. - # It simply needs to have #authenticate method. See http_auth.rb for reference. - # config.admin_auth = 'ComfyAdminAuthentication' + config.admin_auth = 'RSolutions::DeviseAuth' + # Module responsible for authentication. You can replace it with your own. + # It simply needs to have #authenticate method. See http_auth.rb for reference. + # config.admin_auth = 'ComfyAdminAuthentication' - # Module responsible for authorization on admin side. It should have #authorize - # method that returns true or false based on params and loaded instance - # variables available for a given controller. - config.admin_authorization = 'RSolutions::ComfyAdminAuthorization' + # Module responsible for authorization on admin side. It should have #authorize + # method that returns true or false based on params and loaded instance + # variables available for a given controller. + config.admin_authorization = 'RSolutions::ComfyAdminAuthorization' - # Module responsible for public authentication. Similar to the above. You also - # will have access to @cms_site, @cms_layout, @cms_page so you can use them in - # your logic. Default module doesn't do anything. - config.public_auth = 'ComfyPublicAuthentication' + # Module responsible for public authentication. Similar to the above. You also + # will have access to @cms_site, @cms_layout, @cms_page so you can use them in + # your logic. Default module doesn't do anything. + config.public_auth = 'ComfyPublicAuthentication' - # Module responsible for public authorization. It should have #authorize - # method that returns true or false based on params and loaded instance - # variables available for a given controller. - # config.public_authorization = 'ComfyPublicAuthorization' + # Module responsible for public authorization. It should have #authorize + # method that returns true or false based on params and loaded instance + # variables available for a given controller. + # config.public_authorization = 'ComfyPublicAuthorization' - # When arriving at /cms-admin you may chose to redirect to arbirtary path, - # for example '/cms-admin/users' - # config.admin_route_redirect = '' + # When arriving at /cms-admin you may chose to redirect to arbirtary path, + # for example '/cms-admin/users' + # config.admin_route_redirect = '' - # Sofa allows you to setup entire site from files. Database is updated with each - # request (if necessary). Please note that database entries are destroyed if there's - # no corresponding file. Seeds are disabled by default. - # config.enable_seeds = false + # Sofa allows you to setup entire site from files. Database is updated with each + # request (if necessary). Please note that database entries are destroyed if there's + # no corresponding file. Seeds are disabled by default. + # config.enable_seeds = false - # Path where seeds can be located. - # config.seeds_path = File.expand_path('db/cms_seeds', Rails.root) + # Path where seeds can be located. + # config.seeds_path = File.expand_path('db/cms_seeds', Rails.root) - # Content for Layouts, Pages and Snippets has a revision history. You can revert - # a previous version using this system. You can control how many revisions per - # object you want to keep. Set it to 0 if you wish to turn this feature off. - # config.revisions_limit = 25 + # Content for Layouts, Pages and Snippets has a revision history. You can revert + # a previous version using this system. You can control how many revisions per + # object you want to keep. Set it to 0 if you wish to turn this feature off. + # config.revisions_limit = 25 - # Locale definitions. If you want to define your own locale merge - # {:locale => 'Locale Title'} with this. - # config.locales = {:en => 'English', :es => 'Español'} + # Locale definitions. If you want to define your own locale merge + # {:locale => 'Locale Title'} with this. + # config.locales = {:en => 'English', :es => 'Español'} - # Admin interface will respect the locale of the site being managed. However you can - # force it to English by setting this to `:en` - # config.admin_locale = nil + # Admin interface will respect the locale of the site being managed. However you can + # force it to English by setting this to `:en` + # config.admin_locale = nil - # A class that is included as a sweeper to admin base controller if it's set - # config.admin_cache_sweeper = nil + # A class that is included as a sweeper to admin base controller if it's set + # config.admin_cache_sweeper = nil - # By default you cannot have irb code inside your layouts/pages/snippets. - # Generally this is to prevent putting something like this: - # <% User.delete_all %> but if you really want to allow it... - # config.allow_erb = false + # By default you cannot have irb code inside your layouts/pages/snippets. + # Generally this is to prevent putting something like this: + # <% User.delete_all %> but if you really want to allow it... + # config.allow_erb = false - # Whitelist of all helper methods that can be used via {{cms:helper}} tag. By default - # all helpers are allowed except `eval`, `send`, `call` and few others. Empty array - # will prevent rendering of all helpers. - # config.allowed_helpers = nil + # Whitelist of all helper methods that can be used via {{cms:helper}} tag. By default + # all helpers are allowed except `eval`, `send`, `call` and few others. Empty array + # will prevent rendering of all helpers. + # config.allowed_helpers = nil - # Whitelist of partials paths that can be used via {{cms:partial}} tag. All partials - # are accessible by default. Empty array will prevent rendering of all partials. - # config.allowed_partials = nil + # Whitelist of partials paths that can be used via {{cms:partial}} tag. All partials + # are accessible by default. Empty array will prevent rendering of all partials. + # config.allowed_partials = nil - # Site aliases, if you want to have aliases for your site. Good for harmonizing - # production env with dev/testing envs. - # e.g. config.hostname_aliases = {'host.com' => 'host.inv', 'host_a.com' => ['host.lvh.me', 'host.dev']} - # Default is nil (not used) - # config.hostname_aliases = nil + # Site aliases, if you want to have aliases for your site. Good for harmonizing + # production env with dev/testing envs. + # e.g. config.hostname_aliases = {'host.com' => 'host.inv', 'host_a.com' => ['host.lvh.me', 'host.dev']} + # Default is nil (not used) + # config.hostname_aliases = nil - # Reveal partials that can be overwritten in the admin area. - # Default is false. + # Reveal partials that can be overwritten in the admin area. + # Default is false. - #config.reveal_cms_partials = true + #config.reveal_cms_partials = true - # - # Customize the returned content json data - # include fragments in content json - # config.content_json_options = { - # include: [:fragments] - # } + # + # Customize the returned content json data + # include fragments in content json + # config.content_json_options = { + # include: [:fragments] + # } + end end # Uncomment this module and `config.admin_auth` above to use custom admin authentication diff --git a/config/initializers/comfy_blog.rb b/config/initializers/comfy_blog.rb index 5395681ff..423807b05 100644 --- a/config/initializers/comfy_blog.rb +++ b/config/initializers/comfy_blog.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true +Rails.application.reloader.to_prepare do + ComfyBlog.configure do |config| + # application layout to be used to index blog posts + config.app_layout = 'comfy/blog/application' -ComfyBlog.configure do |config| - # application layout to be used to index blog posts - config.app_layout = 'comfy/blog/application' - - # Number of posts per page. Default is 10 - # config.posts_per_page = 10 + # Number of posts per page. Default is 10 + # config.posts_per_page = 10 + end end diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index c0546e62b..a1c550121 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -3,4 +3,4 @@ origins '*' resource '/api/*', headers: :any, methods: [:get, :post, :patch, :put] end -end \ No newline at end of file +end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index ebb97fa9a..f69cebf02 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -8,353 +8,355 @@ # # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. -Devise.setup do |config| - # The secret key used by Devise. Devise uses this key to generate - # random tokens. Changing this key will render invalid all existing - # confirmation, reset password and unlock tokens in the database. - # Devise will use the `secret_key_base` as its `secret_key` - # by default. You can change it below and use your own secret key. - # config.secret_key = 'a116be9cfd11b26c918afb0d608763a4b73877a255f210f9e240f4090ecc997f1a554315185e81b260454de59f0731db3599b882df5d0f96be32710fbb14d6d0' - - # ==> Controller configuration - # Configure the parent class to the devise controllers. - # config.parent_controller = 'DeviseController' - - # ==> Mailer Configuration - # Configure the e-mail address which will be shown in Devise::Mailer, - # note that it will be overwritten if you use your own mailer class - # with default "from" parameter. - config.mailer_sender = "#{Rails.env == 'production' ? 'violet-system' : "violet-#{Rails.env}" }@#{ENV['APP_HOST']}" - - # Configure the class responsible to send e-mails. - # config.mailer = 'Devise::Mailer' - - # Configure the parent class responsible to send e-mails. - # config.parent_mailer = 'ActionMailer::Base' - - # ==> ORM configuration - # Load and configure the ORM. Supports :active_record (default) and - # :mongoid (bson_ext recommended) by default. Other ORMs may be - # available as additional gems. - require 'devise/orm/active_record' - - # ==> Configuration for any authentication mechanism - # Configure which keys are used when authenticating a user. The default is - # just :email. You can configure it to use [:username, :subdomain], so for - # authenticating a user, both parameters are required. Remember that those - # parameters are used only when authenticating and not when retrieving from - # session. If you need permissions, you should implement that in a before filter. - # You can also supply a hash where the value is a boolean determining whether - # or not authentication should be aborted when the value is not present. - # config.authentication_keys = [:email] - - # Configure parameters from the request object used for authentication. Each entry - # given should be a request method and it will automatically be passed to the - # find_for_authentication method and considered in your model lookup. For instance, - # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. - # The same considerations mentioned for authentication_keys also apply to request_keys. - # config.request_keys = [] - - # Configure which authentication keys should be case-insensitive. - # These keys will be downcased upon creating or modifying a user and when used - # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [:email] - - # Configure which authentication keys should have whitespace stripped. - # These keys will have whitespace before and after removed upon creating or - # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [:email] - - # Tell if authentication through request.params is enabled. True by default. - # It can be set to an array that will enable params authentication only for the - # given strategies, for example, `config.params_authenticatable = [:database]` will - # enable it only for database (email + password) authentication. - # config.params_authenticatable = true - - # Tell if authentication through HTTP Auth is enabled. False by default. - # It can be set to an array that will enable http authentication only for the - # given strategies, for example, `config.http_authenticatable = [:database]` will - # enable it only for database authentication. - # For API-only applications to support authentication "out-of-the-box", you will likely want to - # enable this with :database unless you are using a custom strategy. - # The supported strategies are: - # :database = Support basic authentication with authentication key + password - # config.http_authenticatable = false - - # If 401 status code should be returned for AJAX requests. True by default. - # config.http_authenticatable_on_xhr = true - - # The realm used in Http Basic Authentication. 'Application' by default. - # config.http_authentication_realm = 'Application' - - # It will change confirmation, password recovery and other workflows - # to behave the same regardless if the e-mail provided was right or wrong. - # Does not affect registerable. - # config.paranoid = true - - # By default Devise will store the user in session. You can skip storage for - # particular strategies by setting this option. - # Notice that if you are skipping storage for all authentication paths, you - # may want to disable generating routes to Devise's sessions controller by - # passing skip: :sessions to `devise_for` in your config/routes.rb - config.skip_session_storage = [:http_auth] - - # By default, Devise cleans up the CSRF token on authentication to - # avoid CSRF token fixation attacks. This means that, when using AJAX - # requests for sign in and sign up, you need to get a new CSRF token - # from the server. You can disable this option at your own risk. - # config.clean_up_csrf_token_on_authentication = true - - # When false, Devise will not attempt to reload routes on eager load. - # This can reduce the time taken to boot the app but if your application - # requires the Devise mappings to be loaded during boot time the application - # won't boot properly. - # config.reload_routes = true - - # ==> Configuration for :database_authenticatable - # For bcrypt, this is the cost for hashing the password and defaults to 12. If - # using other algorithms, it sets how many times you want the password to be hashed. - # The number of stretches used for generating the hashed password are stored - # with the hashed password. This allows you to change the stretches without - # invalidating existing passwords. - # - # Limiting the stretches to just one in testing will increase the performance of - # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use - # a value less than 10 in other environments. Note that, for bcrypt (the default - # algorithm), the cost increases exponentially with the number of stretches (e.g. - # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). - config.stretches = Rails.env.test? ? 1 : 12 - - # Set up a pepper to generate the hashed password. - # config.pepper = 'd1ccbb924abe03c39aabde69e4986dd04b8d3ed3033a3fff7c9a733f24779c4985dd5291497432210a8afbe1efc9ab53880ecc7f520a5414c64fb5af60e755bf' - - # Send a notification to the original email when the user's email is changed. - # config.send_email_changed_notification = false - - # Send a notification email when the user's password is changed. - # config.send_password_change_notification = false - - # ==> Configuration for :invitable - # The period the generated invitation token is valid. - # After this period, the invited resource won't be able to accept the invitation. - # When invite_for is 0 (the default), the invitation won't expire. - # config.invite_for = 2.weeks - - # Number of invitations users can send. - # - If invitation_limit is nil, there is no limit for invitations, users can - # send unlimited invitations, invitation_limit column is not used. - # - If invitation_limit is 0, users can't send invitations by default. - # - If invitation_limit n > 0, users can send n invitations. - # You can change invitation_limit column for some users so they can send more - # or less invitations, even with global invitation_limit = 0 - # Default: nil - # config.invitation_limit = 5 - - # The key to be used to check existing users when sending an invitation - # and the regexp used to test it when validate_on_invite is not set. - # config.invite_key = { email: /\A[^@]+@[^@]+\z/ } - # config.invite_key = { email: /\A[^@]+@[^@]+\z/, username: nil } - - # Ensure that invited record is valid. - # The invitation won't be sent if this check fails. - # Default: false - # config.validate_on_invite = true - - # Resend invitation if user with invited status is invited again - # Default: true - # config.resend_invitation = false - - # The class name of the inviting model. If this is nil, - # the #invited_by association is declared to be polymorphic. - # Default: nil - # config.invited_by_class_name = 'User' - - # The foreign key to the inviting model (if invited_by_class_name is set) - # Default: :invited_by_id - # config.invited_by_foreign_key = :invited_by_id - - # The column name used for counter_cache column. If this is nil, - # the #invited_by association is declared without counter_cache. - # Default: nil - # config.invited_by_counter_cache = :invitations_count - - # Auto-login after the user accepts the invite. If this is false, - # the user will need to manually log in after accepting the invite. - # Default: true - # config.allow_insecure_sign_in_after_accept = false - - # ==> Configuration for :confirmable - # A period that the user is allowed to access the website even without - # confirming their account. For instance, if set to 2.days, the user will be - # able to access the website for two days without confirming their account, - # access will be blocked just in the third day. - # You can also set it to nil, which will allow the user to access the website - # without confirming their account. - # Default is 0.days, meaning the user cannot access the website without - # confirming their account. - # config.allow_unconfirmed_access_for = 2.days - - # A period that the user is allowed to confirm their account before their - # token becomes invalid. For example, if set to 3.days, the user can confirm - # their account within 3 days after the mail was sent, but on the fourth day - # their account can't be confirmed with the token any more. - # Default is nil, meaning there is no restriction on how long a user can take - # before confirming their account. - # config.confirm_within = 3.days - - # If true, requires any email changes to be confirmed (exactly the same way as - # initial account confirmation) to be applied. Requires additional unconfirmed_email - # db field (see migrations). Until confirmed, new email is stored in - # unconfirmed_email column, and copied to email column on successful confirmation. - config.reconfirmable = true - - # Defines which key will be used when confirming an account - # config.confirmation_keys = [:email] - - # ==> Configuration for :rememberable - # The time the user will be remembered without asking for credentials again. - # config.remember_for = 2.weeks - - # Invalidates all the remember me tokens when the user signs out. - config.expire_all_remember_me_on_sign_out = true - - # If true, extends the user's remember period when remembered via cookie. - # config.extend_remember_period = false - - # Options to be passed to the created cookie. For instance, you can set - # secure: true in order to force SSL only cookies. - # config.rememberable_options = {} - - # ==> Configuration for :validatable - # Range for password length. - config.password_length = 6..128 - - # Email regex used to validate email formats. It simply asserts that - # one (and only one) @ exists in the given string. This is mainly - # to give user feedback and not to assert the e-mail validity. - config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ - - # ==> Configuration for :timeoutable - # The time you want to timeout the user session without activity. After this - # time the user will be asked for credentials again. Default is 30 minutes. - # config.timeout_in = 30.minutes - - # ==> Configuration for :lockable - # Defines which strategy will be used to lock an account. - # :failed_attempts = Locks an account after a number of failed attempts to sign in. - # :none = No lock strategy. You should handle locking by yourself. - # config.lock_strategy = :failed_attempts - - # Defines which key will be used when locking and unlocking an account - # config.unlock_keys = [:email] - - # Defines which strategy will be used to unlock an account. - # :email = Sends an unlock link to the user email - # :time = Re-enables login after a certain amount of time (see :unlock_in below) - # :both = Enables both strategies - # :none = No unlock strategy. You should handle unlocking by yourself. - # config.unlock_strategy = :both - - # Number of authentication tries before locking an account if lock_strategy - # is failed attempts. - # config.maximum_attempts = 20 - - # Time interval to unlock the account if :time is enabled as unlock_strategy. - # config.unlock_in = 1.hour - - # Warn on the last attempt before the account is locked. - # config.last_attempt_warning = true - - # ==> Configuration for :recoverable - # - # Defines which key will be used when recovering the password for an account - # config.reset_password_keys = [:email] - - # Time interval you can reset your password with a reset password key. - # Don't put a too small interval or your users won't have the time to - # change their passwords. - config.reset_password_within = 6.hours - - # When set to false, does not sign a user in automatically after their password is - # reset. Defaults to true, so a user is signed in automatically after a reset. - # config.sign_in_after_reset_password = true - - # ==> Configuration for :encryptable - # Allow you to use another hashing or encryption algorithm besides bcrypt (default). - # You can use :sha1, :sha512 or algorithms from others authentication tools as - # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 - # for default behavior) and :restful_authentication_sha1 (then you should set - # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). - # - # Require the `devise-encryptable` gem when using anything other than bcrypt - # config.encryptor = :sha512 - - # ==> Scopes configuration - # Turn scoped views on. Before rendering "sessions/new", it will first check for - # "users/sessions/new". It's turned off by default because it's slower if you - # are using only default views. - config.scoped_views = true - - # Configure the default scope given to Warden. By default it's the first - # devise role declared in your routes (usually :user). - # config.default_scope = :user - - # Set this configuration to false if you want /users/sign_out to sign out - # only the current scope. By default, Devise signs out all scopes. - # config.sign_out_all_scopes = true - - # ==> Navigation configuration - # Lists the formats that should be treated as navigational. Formats like - # :html, should redirect to the sign in page when the user does not have - # access, but formats like :xml or :json, should return 401. - # - # If you have any extra navigational formats, like :iphone or :mobile, you - # should add them to the navigational formats lists. - # - # The "*/*" below is required to match Internet Explorer requests. - config.navigational_formats = ['*/*', :html, :turbo_stream] - - # The default HTTP method used to sign out a resource. Default is :delete. - config.sign_out_via = :delete - - # ==> OmniAuth - # Add a new OmniAuth provider. Check the wiki for more information on setting - # up on your models and hooks. - # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' - - # ==> Warden configuration - # If you want to use other strategies, that are not supported by Devise, or - # change the failure app, you can configure them inside the config.warden block. - # - # config.warden do |manager| - # manager.intercept_401 = false - # manager.default_strategies(scope: :user).unshift :some_external_strategy - # end - - # ==> Mountable engine configurations - # When using Devise inside an engine, let's call it `MyEngine`, and this engine - # is mountable, there are some extra configurations to be taken into account. - # The following options are available, assuming the engine is mounted as: - # - # mount MyEngine, at: '/my_engine' - # - # The router that invoked `devise_for`, in the example above, would be: - # config.router_name = :my_engine - # - # When using OmniAuth, Devise cannot automatically set OmniAuth path, - # so you need to do it manually. For the users scope, it would be: - # config.omniauth_path_prefix = '/my_engine/users/auth' - - # ==> Turbolinks configuration - # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly: - # - # ActiveSupport.on_load(:devise_failure_app) do - # include Turbolinks::Controller - # end - - # ==> Configuration for :registerable - - # When set to false, does not sign a user in automatically after their password is - # changed. Defaults to true, so a user is signed in automatically after changing a password. - # config.sign_in_after_change_password = true +Rails.application.reloader.to_prepare do + Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + # Devise will use the `secret_key_base` as its `secret_key` + # by default. You can change it below and use your own secret key. + # config.secret_key = 'a116be9cfd11b26c918afb0d608763a4b73877a255f210f9e240f4090ecc997f1a554315185e81b260454de59f0731db3599b882df5d0f96be32710fbb14d6d0' + + # ==> Controller configuration + # Configure the parent class to the devise controllers. + # config.parent_controller = 'DeviseController' + + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = "#{Rails.env == 'production' ? 'violet-system' : "violet-#{Rails.env}" }@#{ENV['APP_HOST']}" + + # Configure the class responsible to send e-mails. + # config.mailer = 'Devise::Mailer' + + # Configure the parent class responsible to send e-mails. + # config.parent_mailer = 'ActionMailer::Base' + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [:email] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [:email] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [:email] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. + # For API-only applications to support authentication "out-of-the-box", you will likely want to + # enable this with :database unless you are using a custom strategy. + # The supported strategies are: + # :database = Support basic authentication with authentication key + password + # config.http_authenticatable = false + + # If 401 status code should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + + # When false, Devise will not attempt to reload routes on eager load. + # This can reduce the time taken to boot the app but if your application + # requires the Devise mappings to be loaded during boot time the application + # won't boot properly. + # config.reload_routes = true + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 12. If + # using other algorithms, it sets how many times you want the password to be hashed. + # The number of stretches used for generating the hashed password are stored + # with the hashed password. This allows you to change the stretches without + # invalidating existing passwords. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # algorithm), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 12 + + # Set up a pepper to generate the hashed password. + # config.pepper = 'd1ccbb924abe03c39aabde69e4986dd04b8d3ed3033a3fff7c9a733f24779c4985dd5291497432210a8afbe1efc9ab53880ecc7f520a5414c64fb5af60e755bf' + + # Send a notification to the original email when the user's email is changed. + # config.send_email_changed_notification = false + + # Send a notification email when the user's password is changed. + # config.send_password_change_notification = false + + # ==> Configuration for :invitable + # The period the generated invitation token is valid. + # After this period, the invited resource won't be able to accept the invitation. + # When invite_for is 0 (the default), the invitation won't expire. + # config.invite_for = 2.weeks + + # Number of invitations users can send. + # - If invitation_limit is nil, there is no limit for invitations, users can + # send unlimited invitations, invitation_limit column is not used. + # - If invitation_limit is 0, users can't send invitations by default. + # - If invitation_limit n > 0, users can send n invitations. + # You can change invitation_limit column for some users so they can send more + # or less invitations, even with global invitation_limit = 0 + # Default: nil + # config.invitation_limit = 5 + + # The key to be used to check existing users when sending an invitation + # and the regexp used to test it when validate_on_invite is not set. + # config.invite_key = { email: /\A[^@]+@[^@]+\z/ } + # config.invite_key = { email: /\A[^@]+@[^@]+\z/, username: nil } + + # Ensure that invited record is valid. + # The invitation won't be sent if this check fails. + # Default: false + # config.validate_on_invite = true + + # Resend invitation if user with invited status is invited again + # Default: true + # config.resend_invitation = false + + # The class name of the inviting model. If this is nil, + # the #invited_by association is declared to be polymorphic. + # Default: nil + # config.invited_by_class_name = 'User' + + # The foreign key to the inviting model (if invited_by_class_name is set) + # Default: :invited_by_id + # config.invited_by_foreign_key = :invited_by_id + + # The column name used for counter_cache column. If this is nil, + # the #invited_by association is declared without counter_cache. + # Default: nil + # config.invited_by_counter_cache = :invitations_count + + # Auto-login after the user accepts the invite. If this is false, + # the user will need to manually log in after accepting the invite. + # Default: true + # config.allow_insecure_sign_in_after_accept = false + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. + # You can also set it to nil, which will allow the user to access the website + # without confirming their account. + # Default is 0.days, meaning the user cannot access the website without + # confirming their account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [:email] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. + config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [:email] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # Warn on the last attempt before the account is locked. + # config.last_attempt_warning = true + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [:email] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # When set to false, does not sign a user in automatically after their password is + # reset. Defaults to true, so a user is signed in automatically after a reset. + # config.sign_in_after_reset_password = true + + # ==> Configuration for :encryptable + # Allow you to use another hashing or encryption algorithm besides bcrypt (default). + # You can use :sha1, :sha512 or algorithms from others authentication tools as + # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 + # for default behavior) and :restful_authentication_sha1 (then you should set + # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + # config.encryptor = :sha512 + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + config.scoped_views = true + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + config.navigational_formats = ['*/*', :html, :turbo_stream] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(scope: :user).unshift :some_external_strategy + # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using OmniAuth, Devise cannot automatically set OmniAuth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' + + # ==> Turbolinks configuration + # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly: + # + # ActiveSupport.on_load(:devise_failure_app) do + # include Turbolinks::Controller + # end + + # ==> Configuration for :registerable + + # When set to false, does not sign a user in automatically after their password is + # changed. Defaults to true, so a user is signed in automatically after changing a password. + # config.sign_in_after_change_password = true + end end diff --git a/config/initializers/ember.rb b/config/initializers/ember.rb index 28ac73d82..8096195d4 100644 --- a/config/initializers/ember.rb +++ b/config/initializers/ember.rb @@ -1,5 +1,7 @@ -if RUBY_VERSION != '3.0.0' - EmberCli.configure do |c| - c.app :client +if RUBY_VERSION != '3.0.0' && ENV['EMBER_ENABLED'] + Rails.application.reloader.to_prepare do + EmberCli.configure do |c| + c.app :client + end end end diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb index d557afe8c..b568963ae 100644 --- a/config/initializers/friendly_id.rb +++ b/config/initializers/friendly_id.rb @@ -8,100 +8,101 @@ # To learn more, check out the guide: # # http://norman.github.io/friendly_id/file.Guide.html +Rails.application.reloader.to_prepare do + FriendlyId.defaults do |config| + # ## Reserved Words + # + # Some words could conflict with Rails's routes when used as slugs, or are + # undesirable to allow as slugs. Edit this list as needed for your app. + config.use :reserved -FriendlyId.defaults do |config| - # ## Reserved Words - # - # Some words could conflict with Rails's routes when used as slugs, or are - # undesirable to allow as slugs. Edit this list as needed for your app. - config.use :reserved + config.reserved_words = %w(new edit index session login logout users admin + stylesheets assets javascripts images) + + # This adds an option to treat reserved words as conflicts rather than exceptions. + # When there is no good candidate, a UUID will be appended, matching the existing + # conflict behavior. - config.reserved_words = %w(new edit index session login logout users admin - stylesheets assets javascripts images) - - # This adds an option to treat reserved words as conflicts rather than exceptions. - # When there is no good candidate, a UUID will be appended, matching the existing - # conflict behavior. + # config.treat_reserved_as_conflict = true - # config.treat_reserved_as_conflict = true - - # ## Friendly Finders - # - # Uncomment this to use friendly finders in all models. By default, if - # you wish to find a record by its friendly id, you must do: - # - # MyModel.friendly.find('foo') - # - # If you uncomment this, you can do: - # - # MyModel.find('foo') - # - # This is significantly more convenient but may not be appropriate for - # all applications, so you must explicity opt-in to this behavior. You can - # always also configure it on a per-model basis if you prefer. - # - # Something else to consider is that using the :finders addon boosts - # performance because it will avoid Rails-internal code that makes runtime - # calls to `Module.extend`. - # - # config.use :finders - # - # ## Slugs - # - # Most applications will use the :slugged module everywhere. If you wish - # to do so, uncomment the following line. - # - # config.use :slugged - # - # By default, FriendlyId's :slugged addon expects the slug column to be named - # 'slug', but you can change it if you wish. - # - # config.slug_column = 'slug' - # - # By default, slug has no size limit, but you can change it if you wish. - # - # config.slug_limit = 255 - # - # When FriendlyId can not generate a unique ID from your base method, it appends - # a UUID, separated by a single dash. You can configure the character used as the - # separator. If you're upgrading from FriendlyId 4, you may wish to replace this - # with two dashes. - # - # config.sequence_separator = '-' - # - # Note that you must use the :slugged addon **prior** to the line which - # configures the sequence separator, or else FriendlyId will raise an undefined - # method error. - # - # ## Tips and Tricks - # - # ### Controlling when slugs are generated - # - # As of FriendlyId 5.0, new slugs are generated only when the slug field is - # nil, but if you're using a column as your base method can change this - # behavior by overriding the `should_generate_new_friendly_id?` method that - # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave - # more like 4.0. - # Note: Use(include) Slugged module in the config if using the anonymous module. - # If you have `friendly_id :name, use: slugged` in the model, Slugged module - # is included after the anonymous module defined in the initializer, so it - # overrides the `should_generate_new_friendly_id?` method from the anonymous module. - # - # config.use :slugged - # config.use Module.new { - # def should_generate_new_friendly_id? - # slug.blank? || _changed? - # end - # } - # - # FriendlyId uses Rails's `parameterize` method to generate slugs, but for - # languages that don't use the Roman alphabet, that's not usually sufficient. - # Here we use the Babosa library to transliterate Russian Cyrillic slugs to - # ASCII. If you use this, don't forget to add "babosa" to your Gemfile. - # - # config.use Module.new { - # def normalize_friendly_id(text) - # text.to_slug.normalize! :transliterations => [:russian, :latin] - # end - # } + # ## Friendly Finders + # + # Uncomment this to use friendly finders in all models. By default, if + # you wish to find a record by its friendly id, you must do: + # + # MyModel.friendly.find('foo') + # + # If you uncomment this, you can do: + # + # MyModel.find('foo') + # + # This is significantly more convenient but may not be appropriate for + # all applications, so you must explicity opt-in to this behavior. You can + # always also configure it on a per-model basis if you prefer. + # + # Something else to consider is that using the :finders addon boosts + # performance because it will avoid Rails-internal code that makes runtime + # calls to `Module.extend`. + # + # config.use :finders + # + # ## Slugs + # + # Most applications will use the :slugged module everywhere. If you wish + # to do so, uncomment the following line. + # + # config.use :slugged + # + # By default, FriendlyId's :slugged addon expects the slug column to be named + # 'slug', but you can change it if you wish. + # + # config.slug_column = 'slug' + # + # By default, slug has no size limit, but you can change it if you wish. + # + # config.slug_limit = 255 + # + # When FriendlyId can not generate a unique ID from your base method, it appends + # a UUID, separated by a single dash. You can configure the character used as the + # separator. If you're upgrading from FriendlyId 4, you may wish to replace this + # with two dashes. + # + # config.sequence_separator = '-' + # + # Note that you must use the :slugged addon **prior** to the line which + # configures the sequence separator, or else FriendlyId will raise an undefined + # method error. + # + # ## Tips and Tricks + # + # ### Controlling when slugs are generated + # + # As of FriendlyId 5.0, new slugs are generated only when the slug field is + # nil, but if you're using a column as your base method can change this + # behavior by overriding the `should_generate_new_friendly_id?` method that + # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave + # more like 4.0. + # Note: Use(include) Slugged module in the config if using the anonymous module. + # If you have `friendly_id :name, use: slugged` in the model, Slugged module + # is included after the anonymous module defined in the initializer, so it + # overrides the `should_generate_new_friendly_id?` method from the anonymous module. + # + # config.use :slugged + # config.use Module.new { + # def should_generate_new_friendly_id? + # slug.blank? || _changed? + # end + # } + # + # FriendlyId uses Rails's `parameterize` method to generate slugs, but for + # languages that don't use the Roman alphabet, that's not usually sufficient. + # Here we use the Babosa library to transliterate Russian Cyrillic slugs to + # ASCII. If you use this, don't forget to add "babosa" to your Gemfile. + # + # config.use Module.new { + # def normalize_friendly_id(text) + # text.to_slug.normalize! :transliterations => [:russian, :latin] + # end + # } + end end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index d42f6f533..ecf58e6b5 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,2 +1,4 @@ -Sidekiq.configure_server { |c| c.redis = { url: ENV['REDIS_URL'] } } -Sidekiq.strict_args! +Rails.application.reloader.to_prepare do + Sidekiq.configure_server { |c| c.redis = { url: ENV['REDIS_URL'] } } + Sidekiq.strict_args! +end diff --git a/config/initializers/web_console.rb b/config/initializers/web_console.rb index e46921830..c6bff8ad6 100644 --- a/config/initializers/web_console.rb +++ b/config/initializers/web_console.rb @@ -1,4 +1,4 @@ - +Rails.application.reloader.to_prepare do module WebConsole class Permissions # monkey patch for dynamically allowing web console rendering @@ -7,3 +7,4 @@ def include?(network) end end end +end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index bbfc3961b..8bbab7bef 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -4,8 +4,10 @@ # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] +Rails.application.reloader.to_prepare do + ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] + end end # To enable root element in JSON for ActiveRecord objects. diff --git a/config/routes.rb b/config/routes.rb index 9f7680a64..12e0288e4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,7 +133,7 @@ def self.matches?(request) post "/graphql", to: "graphql#execute" # catch web client route before it gets hijacked by the server - if RUBY_VERSION != "3.0.0" + if RUBY_VERSION != "3.0.0" && ENV["EMBER_ENABLED"] mount_ember_app :client, to: "/app" end