GRN2-xx: Hide signin when error occures (#2221)

* Hide signin when error occures

* Rubocop fixes
This commit is contained in:
Ahmad Farhat 2020-10-23 10:01:19 -04:00 committed by GitHub
parent 0801c626c5
commit 0ff938a0fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 5 deletions

View File

@ -259,24 +259,40 @@ class ApplicationController < ActionController::Base
session[:provider_exists] = @user_domain session[:provider_exists] = @user_domain
rescue => e rescue => e
logger.error "Error in retrieve provider info: #{e}" logger.error "Error in retrieve provider info: #{e}"
# Use the default site settings @hide_signin = true
@user_domain = "greenlight"
@settings = Setting.find_or_create_by(provider: @user_domain)
if e.message.eql? "No user with that id exists" 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"), 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") } help: I18n.t("errors.not_found.user_not_found.help") }
elsif e.message.eql? "Provider not included." elsif e.message.eql? "Provider not included."
set_default_settings
render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_missing.message"), render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_missing.message"),
help: I18n.t("errors.not_found.user_missing.help") } help: I18n.t("errors.not_found.user_missing.help") }
elsif e.message.eql? "That user has no configured provider." 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, render "errors/greenlight_error", locals: { status_code: 501,
message: I18n.t("errors.no_provider.message"), message: I18n.t("errors.no_provider.message"),
help: I18n.t("errors.no_provider.help") } help: I18n.t("errors.no_provider.help") }
else else
set_default_settings
render "errors/greenlight_error", locals: { status_code: 500, message: I18n.t("errors.internal.message"), render "errors/greenlight_error", locals: { status_code: 500, message: I18n.t("errors.internal.message"),
help: I18n.t("errors.internal.help"), display_back: true } help: I18n.t("errors.internal.help"), display_back: true }
end end
end 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 end

View File

@ -130,4 +130,9 @@ module ApplicationHelper
return false unless recording_consent_required? return false unless recording_consent_required?
@settings.get_value("Room Configuration Recording") == "disabled" @settings.get_value("Room Configuration Recording") == "disabled"
end end
# Hide the signin buttons if there is an error on the page
def show_signin
!@hide_signin.present?
end
end end

View File

@ -88,7 +88,7 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<% else %> <% elsif show_signin %>
<% allow_greenlight_accounts = allow_greenlight_accounts? %> <% allow_greenlight_accounts = allow_greenlight_accounts? %>
<% if allow_greenlight_accounts %> <% if allow_greenlight_accounts %>
<%= link_to t("login"), signin_path, :class => "btn btn-outline-primary mx-2 sign-in-button" %> <%= link_to t("login"), signin_path, :class => "btn btn-outline-primary mx-2 sign-in-button" %>