[bbb-greenlight: 5/12] GRN2-xx: Hide signin when error occures (#2221)
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bbb-greenlight: 5/12] GRN2-xx: Hide signin when error occures (#2221)
- Date: Wed, 28 Oct 2020 07:03:38 +0000 (UTC)
commit 0ff938a0fdcbdff0cfc5cbc82933336bed04312b
Author: Ahmad Farhat <ahmad af farhat gmail com>
Date: Fri Oct 23 10:01:19 2020 -0400
GRN2-xx: Hide signin when error occures (#2221)
* Hide signin when error occures
* Rubocop fixes
app/controllers/application_controller.rb | 24 ++++++++++++++++++++----
app/helpers/application_helper.rb | 5 +++++
app/views/shared/_header.html.erb | 2 +-
3 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1b8a62e..4a89a73 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 dff6e29..2a9c007 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 22f0a95..21ffaaf 100755
--- a/app/views/shared/_header.html.erb
+++ b/app/views/shared/_header.html.erb
@@ -88,7 +88,7 @@
<% end %>
</div>
</div>
- <% 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" %>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]