OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Show protocol and hostname mismatch warning
Oliver Günther522fc5cdea5a
diff --git a/app/helpers/warning_bar_helper.rb b/app/helpers/warning_bar_helper.rbindex 631b686fd6d..217040cd1e1 100644--- a/app/helpers/warning_bar_helper.rb+++ b/app/helpers/warning_bar_helper.rb@@ -35,6 +35,20 @@ module WarningBarHelperOpenProject::Database.migrations_pending?end+ def render_host_and_protocol_mismatch?+ current_user.admin? &&+ OpenProject::Configuration.show_setting_mismatch_warning? &&+ (setting_protocol_mismatched? || setting_hostname_mismatched?)+ end++ def setting_protocol_mismatched?+ (request.ssl? && Setting.protocol == 'http') || (!request.ssl? && Setting.protocol == 'https')+ end++ def setting_hostname_mismatched?+ Setting.host_name.gsub(/:\d+$/, '') != request.host+ end+### By default, never show a warning bar in the# test mode due to overshadowing other elements.diff --git a/app/views/warning_bar/_host_and_protocol_mismatch.html.erb b/app/views/warning_bar/_host_and_protocol_mismatch.html.erbnew file mode 100644index 00000000000..fe74f386bca--- /dev/null+++ b/app/views/warning_bar/_host_and_protocol_mismatch.html.erb@@ -0,0 +1,28 @@+<div id="pending-migrations-warning" class="warning-bar--item unsupported-browser-warning--pane">+ <span class="icon3 icon-warning"></span>++ <% if setting_protocol_mismatched? %>+ <p>+ <strong><%= t 'warning_bar.protocol_mismatch.title' %></strong>+ <br/>+ <%= t 'warning_bar.protocol_mismatch.text_html',+ set_protocol: Setting.protocol,+ actual_protocol: request.ssl? ? 'https' : 'http',+ setting_path: settings_path+ %>+ </p>+ <% end %>++ <% if setting_hostname_mismatched? %>+ <p>+ <strong><%= t 'warning_bar.hostname_mismatch.title' %></strong>+ <br/>+ <%= t 'warning_bar.hostname_mismatch.text_html',+ set_hostname: Setting.host_name,+ actual_hostname: request.host,+ setting_path: settings_path+ %>+ </p>+ <% end %>++</div>diff --git a/app/views/warning_bar/_warning_bar.html.erb b/app/views/warning_bar/_warning_bar.html.erbindex 00fc67f915b..fc369ea217e 100644--- a/app/views/warning_bar/_warning_bar.html.erb+++ b/app/views/warning_bar/_warning_bar.html.erb@@ -1,5 +1,6 @@<% if show_warning_bar? %><div class="warning-bar--wrapper">+ <%= render partial: 'warning_bar/host_and_protocol_mismatch' if render_host_and_protocol_mismatch? %><%= render partial: 'warning_bar/pending_migrations' if render_pending_migrations_warning? %><%= render partial: 'warning_bar/unsupported_browser' if unsupported_browser? %></div>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 5a7d1654acb..c7ccefad10c 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2652,6 +2652,21 @@ en:warning_user_limit_reached_instructions: >You reached your user limit (%{current}/%{max} active users).Please contact [email protected] to upgrade your Enterprise Edition plan and add additional users.+ warning_protocol_mismatch_html: >++ warning_bar:+ protocol_mismatch:+ title: 'Protocol setting mismatch'+ text_html: >+ Your application is running with its protocol setting set to <code>%{set_protocol}</code>, but the request+ is an <code>%{actual_protocol}</code> request.+ This will result in errors! Go to <a href="%{setting_path}">System settings</a> and change the "Protocol" setting to correct this.+ hostname_mismatch:+ title: 'Hostname setting mismatch'+ text_html: >+ Your application is running with its host name setting set to <code>%{set_hostname}</code>, but the request+ is a <code>%{actual_hostname}</code> hostname.+ This will result in errors! Go to <a href="%{setting_path}">System settings</a> and change the "Host name" setting to correct this.menu_item: "Menu item"menu_item_setting: "Visibility"diff --git a/frontend/src/app/globals/global-listeners.ts b/frontend/src/app/globals/global-listeners.tsindex 0d2c3f7ae9b..bfce7978b97 100644--- a/frontend/src/app/globals/global-listeners.ts+++ b/frontend/src/app/globals/global-listeners.ts@@ -73,6 +73,14 @@ import {scrollHeaderOnMobile} from "core-app/globals/global-listeners/top-menu-swindow.OpenProject.pageIsSubmitted = true;});+ // Add to content if warnings displayed+ if (document.querySelector('.warning-bar--item')) {+ let content = document.querySelector('#content') as HTMLElement;+ if (content) {+ content.style.marginBottom = '100px';+ }+ }+// Global beforeunload hook$(window).on('beforeunload', (e:JQuery.TriggeredEvent) => {const event = e.originalEvent as BeforeUnloadEvent;diff --git a/lib/open_project/configuration.rb b/lib/open_project/configuration.rbindex a4a31f7860e..e0a7ed4ed3b 100644--- a/lib/open_project/configuration.rb+++ b/lib/open_project/configuration.rb@@ -152,6 +152,10 @@ module OpenProject# Show pending migrations as warning bar'show_pending_migrations_warning' => true,+ # Show mismatched protocol/hostname warning+ # in settings where they must differ this can be disabled+ 'show_setting_mismatch_warning' => true,+# Render warning bars (pending migrations, deprecation, unsupported browsers)# Set to false to globally disable this for all users!'show_warning_bars' => true,