diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index a2f0ffd35..bb56ad212 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -1032,14 +1032,14 @@ angular.module('application.router', ['ui.router']) resolve: { settingsPromise: ['Setting', function (Setting) { return Setting.query({ - names: `['twitter_name', 'about_title', 'about_body', 'tracking_id', 'facebook_app_id', 'base_url_host', \ + names: `['twitter_name', 'about_title', 'about_body', 'tracking_id', 'facebook_app_id', \ 'privacy_body', 'privacy_dpo', 'about_contacts', 'book_overlapping_slots', 'invoicing_module', \ 'home_blogpost', 'machine_explications_alert', 'training_explications_alert', 'slot_duration', \ 'training_information_message', 'subscription_explications_alert', 'event_explications_alert', \ 'space_explications_alert', 'booking_window_start', 'booking_window_end', 'events_in_calendar', \ 'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', 'feature_tour_display', \ 'booking_cancel_delay', 'main_color', 'secondary_color', 'spaces_module', 'twitter_analytics', \ - 'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', 'base_url_protocol', \ + 'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', \ 'reminder_delay', 'visibility_yearly', 'visibility_others', 'email_from', \ 'display_name_enable', 'machines_sort_by', 'fab_analytics', \ 'link_name', 'home_content', 'home_css', 'phone_required']` }).$promise; diff --git a/app/assets/templates/admin/settings/general.html b/app/assets/templates/admin/settings/general.html index c07851cfe..3a53a5075 100644 --- a/app/assets/templates/admin/settings/general.html +++ b/app/assets/templates/admin/settings/general.html @@ -380,34 +380,6 @@ -
Your members will receive email notifications containing links to this instance of Fab-manager. You must properly configure the URL of this instance, to prevent broken links.
To prevent any mistake, please favor the use of the button {NAME} below.
The host name is also used for visits statistics.
" - protocol: "Protocol" - host: "Host" privacy: title: "Privacy" privacy_policy: "Privacy policy" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 25d26309a..ba0902e4d 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -1057,9 +1057,6 @@ fr: recaptcha_secret_key: "clef secrète reCAPTCHA" feature_tour_display: "l'affichage des visites guidées" email_from: "l'adresse de l'expéditeur" - base_url_protocol: "protocole du site" - base_url_host: "l'hôte du site" - base_url: "l'url du site" disqus_shortname: "nom court Disqus" general: general: "Général" @@ -1094,11 +1091,6 @@ fr: email: "Courriel" email_info: "L'adresse de courriel depuis laquelle les notifications seront envoyées. Vous pouvez utiliser une adresse qui n'existe pas (comme ne-pas-repondre@...) ou une adresse existante si vous voulez que vos membres puisse répondre aux notifications qu'ils reçoivent." email_from: "Adresse de l'expéditeur" - site_url: "URL du site" - auto_fill: "Détecter et remplir" - site_url_info_html: "Vos membres recevront les notifications par courriel contenant des liens vers cette instance de Fab-manager. Vous devez configurer correctement l'URL de cette instance, pour éviter les liens cassés.
Pour éviter toute erreur, veuillez favoriser l'utilisation du bouton {NAME} ci-dessous.
Le nom d'hôte est également utilisé pour les statistiques de visites.
" - protocol: "Protocole" - host: "Hôte" privacy: title: "Confidentialité" privacy_policy: "Politique de confidentialité" diff --git a/config/secrets.yml b/config/secrets.yml index 219af62a1..bb2f52d77 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -18,6 +18,8 @@ development: fablab_without_online_payments: <%= ENV["FABLAB_WITHOUT_ONLINE_PAYMENT"] %> fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %> user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %> + default_host: <%= ENV["DEFAULT_HOST"] %> + default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> time_zone: <%= ENV["TIME_ZONE"] %> week_starting_day: <%= ENV["WEEK_STARTING_DAY"] %> d3_date_format: <%= ENV["D3_DATE_FORMAT"].dump %> # .dump is needed as the value may start by a '%', see https://github.com/tenderlove/psych/issues/75 @@ -52,6 +54,8 @@ test: fablab_without_online_payments: false fablab_without_wallet: false user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %> + default_host: <%= ENV["DEFAULT_HOST"] %> + default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> time_zone: Paris week_starting_day: monday d3_date_format: '%d/%m/%y' @@ -86,6 +90,8 @@ staging: fablab_without_online_payments: <%= ENV["FABLAB_WITHOUT_ONLINE_PAYMENT"] %> fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %> user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %> + default_host: <%= ENV["DEFAULT_HOST"] %> + default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> delivery_method: <%= ENV['DELIVERY_METHOD'] %> smtp_address: <%= ENV["SMTP_ADDRESS"] %> smtp_port: <%= ENV["SMTP_PORT"] %> @@ -131,6 +137,8 @@ production: fablab_without_online_payments: <%= ENV["FABLAB_WITHOUT_ONLINE_PAYMENT"] %> fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %> user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %> + default_host: <%= ENV["DEFAULT_HOST"] %> + default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> delivery_method: <%= ENV['DELIVERY_METHOD'] %> smtp_address: <%= ENV["SMTP_ADDRESS"] %> smtp_port: <%= ENV["SMTP_PORT"] %> diff --git a/db/seeds.rb b/db/seeds.rb index 3ab84189c..de87fd7b1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -859,10 +859,6 @@ Setting.set('feature_tour_display', 'once') unless Setting.find_by(name: 'featur Setting.set('email_from', 'noreply@fab-manager.com') unless Setting.find_by(name: 'email_from').try(:value) -Setting.set('base_url_host', 'demo.fab-manager.com') unless Setting.find_by(name: 'base_url_host').try(:value) - -Setting.set('base_url_protocol', 'https') unless Setting.find_by(name: 'base_url_protocol').try(:value) - if StatisticCustomAggregation.count.zero? # available reservations hours for machines machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2) diff --git a/doc/environment.md b/doc/environment.md index 6878f8180..a0a947d0a 100644 --- a/doc/environment.md +++ b/doc/environment.md @@ -105,12 +105,20 @@ Set to 'false' if you don't want this behaviour. Configure the Rails' Action Mailer delivery method. See http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration for more details. - + SMTP_ADDRESS, SMTP_PORT, SMTP_USER_NAME, SMTP_PASSWORD, SMTP_AUTHENTICATION, SMTP_ENABLE_STARTTLS_AUTO, SMTP_OPENSSL_VERIFY_MODE & SMTP_TLS When DELIVERY_METHOD is set to **smtp**, configure the SMTP server parameters. See https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration for more details. + + + DEFAULT_HOST, DEFAULT_PROTOCOL + +Your members will receive email notifications containing links to your of Fab-manager. +You must properly configure these variables to match URL of this instance, to prevent broken links. +Typically, `DEFAULT_PROTOCOL` will be `https` (`http` if you are in development, or if you set `ALLOW_INSECURE_HTTP`). +The variable `DEFAULT_HOST` should be your domain name (eg. fabmanager.example.com), and is also used for visits statistics (configuration of Google Analytics). LOG_LEVEL diff --git a/env.example b/env.example index 94cac4f10..50f1b8626 100644 --- a/env.example +++ b/env.example @@ -22,6 +22,10 @@ FABLAB_WITHOUT_WALLET=false USER_CONFIRMATION_NEEDED_TO_SIGN_IN=false +# Configure carefully! +DEFAULT_HOST=localhost:5000 +DEFAULT_PROTOCOL=http + # Email config DELIVERY_METHOD=smtp SMTP_ADDRESS= diff --git a/lib/fab_hub.rb b/lib/fab_hub.rb index 0bb7888f0..36468b6a5 100644 --- a/lib/fab_hub.rb +++ b/lib/fab_hub.rb @@ -4,7 +4,7 @@ class FabHub def self.version_check_payload uuid = Setting.get('uuid') - origin = Setting.get('origin') || "#{Setting.get('base_url_protocol')}://#{Setting.get('base_url_host')}" + origin = Setting.get('origin') || "#{Rails.application.secrets.default_protocol}://#{Rails.application.secrets.default_host}" { uuid: uuid, origin: origin, diff --git a/lib/tasks/fablab/setup.rake b/lib/tasks/fablab/setup.rake index 74d64b1dd..9a9f3df20 100644 --- a/lib/tasks/fablab/setup.rake +++ b/lib/tasks/fablab/setup.rake @@ -120,8 +120,6 @@ namespace :fablab do %w[_ RECAPTCHA_SECRET_KEY recaptcha_secret_key], %w[_ FEATURE_TOUR_DISPLAY feature_tour_display once], %w[_ DEFAULT_MAIL_FROM email_from], - %w[_ DEFAULT_HOST base_url_host demo.fab-manager.com], - %w[_ DEFAULT_PROTOCOL base_url_protocol https], %w[_ DISQUS_SHORTNAME disqus_shortname] ] diff --git a/setup/env.example b/setup/env.example index d46a69b6b..a2d827228 100644 --- a/setup/env.example +++ b/setup/env.example @@ -16,6 +16,9 @@ FABLAB_WITHOUT_WALLET=false SLOT_DURATION=60 FEATURE_TOUR_DISPLAY=once +DEFAULT_HOST=demo.fab-manager.com +DEFAULT_PROTOCOL=http + DELIVERY_METHOD=smtp SMTP_ADDRESS=smtp.sendgrid.net SMTP_PORT=587 diff --git a/setup/setup.sh b/setup/setup.sh index 4f53814bf..c1adff54c 100755 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -235,7 +235,7 @@ configure_env_file() local doc variables secret doc=$(\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/doc/environment.md) variables=(STRIPE_API_KEY STRIPE_PUBLISHABLE_KEY STRIPE_CURRENCY INVOICE_PREFIX FABLAB_WITHOUT_ONLINE_PAYMENT FABLAB_WITHOUT_WALLET \ - USER_CONFIRMATION_NEEDED_TO_SIGN_IN DELIVERY_METHOD SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \ + USER_CONFIRMATION_NEEDED_TO_SIGN_IN DEFAULT_HOST DEFAULT_PROTOCOL DELIVERY_METHOD SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \ SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS \ LOG_LEVEL ALLOWED_EXTENSIONS ALLOWED_MIME_TYPES MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \ SUPERADMIN_EMAIL APP_LOCALE RAILS_LOCALE MOMENT_LOCALE SUMMERNOTE_LOCALE ANGULAR_LOCALE FULLCALENDAR_LOCALE ELASTICSEARCH_LANGUAGE_ANALYZER TIME_ZONE \ diff --git a/test/fixtures/history_values.yml b/test/fixtures/history_values.yml index 96c802623..e045e6767 100644 --- a/test/fixtures/history_values.yml +++ b/test/fixtures/history_values.yml @@ -629,21 +629,3 @@ history_value_65: created_at: 2020-06-01 11:12:21.255550000 Z updated_at: 2020-06-01 11:12:21.255550000 Z footprint: - -history_value_66: - id: 66 - setting_id: 66 - invoicing_profile_id: 1 - value: 'demo.fab-manager.com' - created_at: 2020-06-01 17:34:41.422150000 Z - updated_at: 2020-06-01 17:34:41.422150000 Z - footprint: - -history_value_67: - id: 67 - setting_id: 67 - invoicing_profile_id: 1 - value: 'https' - created_at: 2020-06-01 17:34:41.422150000 Z - updated_at: 2020-06-01 17:34:41.422150000 Z - footprint: diff --git a/test/fixtures/settings.yml b/test/fixtures/settings.yml index 01f1a9b54..67c28681e 100644 --- a/test/fixtures/settings.yml +++ b/test/fixtures/settings.yml @@ -382,16 +382,3 @@ setting_65: name: email_from created_at: 2020-06-01 11:12:21.255550000 Z updated_at: 2020-06-01 11:12:21.255550000 Z - -setting_66: - id: 66 - name: base_url_host - created_at: 2020-06-01 17:34:41.422150000 Z - updated_at: 2020-06-01 17:34:41.422150000 Z - -setting_67: - id: 67 - name: base_url_protocol - created_at: 2020-06-01 17:34:41.422150000 Z - updated_at: 2020-06-01 17:34:41.422150000 Z -