diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1b8a62e8..4a89a73a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -259,24 +259,40 @@ class ApplicationController < ActionController::Base session[:provider_exists] = @user_domain rescue => e logger.error "Error in retrieve provider info: #{e}" - # Use the default site settings - @user_domain = "greenlight" - @settings = Setting.find_or_create_by(provider: @user_domain) - + @hide_signin = true if e.message.eql? "No user with that id exists" + set_default_settings + render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_not_found.message"), help: I18n.t("errors.not_found.user_not_found.help") } elsif e.message.eql? "Provider not included." + set_default_settings + render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_missing.message"), help: I18n.t("errors.not_found.user_missing.help") } elsif e.message.eql? "That user has no configured provider." + if Setting.exists(provider: @user_domain) + # Keep the branding + @settings = Setting.find_by(provider: @user_domain) + else + set_default_settings + end + render "errors/greenlight_error", locals: { status_code: 501, message: I18n.t("errors.no_provider.message"), help: I18n.t("errors.no_provider.help") } else + set_default_settings + render "errors/greenlight_error", locals: { status_code: 500, message: I18n.t("errors.internal.message"), help: I18n.t("errors.internal.help"), display_back: true } end end end + + def set_default_settings + # Use the default site settings + @user_domain = "greenlight" + @settings = Setting.find_or_create_by(provider: @user_domain) + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dff6e29b..2a9c0074 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -130,4 +130,9 @@ module ApplicationHelper return false unless recording_consent_required? @settings.get_value("Room Configuration Recording") == "disabled" end + + # Hide the signin buttons if there is an error on the page + def show_signin + !@hide_signin.present? + end end diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index 22f0a957..21ffaaf8 100755 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -88,7 +88,7 @@ <% end %> - <% else %> + <% elsif show_signin %> <% allow_greenlight_accounts = allow_greenlight_accounts? %> <% if allow_greenlight_accounts %> <%= link_to t("login"), signin_path, :class => "btn btn-outline-primary mx-2 sign-in-button" %>