From ee260361050bcafd09ddff5edf5f5a85de6762a7 Mon Sep 17 00:00:00 2001
From: shawn-higgins1 <23224097+shawn-higgins1@users.noreply.github.com>
Date: Mon, 22 Jul 2019 12:33:53 -0400
Subject: [PATCH] Unify error pages (#674)
* Unify error pages
* Start travis
---
app/controllers/application_controller.rb | 13 +++++--
app/controllers/errors_controller.rb | 13 +++++--
app/views/errors/greenlight_error.html.erb | 39 +++++++++++++++++++
app/views/errors/internal_error.html.erb | 23 -----------
app/views/errors/not_found.html.erb | 28 -------------
app/views/errors/unauthorized.html.erb | 20 ----------
config/locales/en.yml | 3 ++
spec/controllers/admins_controller_spec.rb | 2 +-
.../application_controller_spec.rb | 6 +--
9 files changed, 65 insertions(+), 82 deletions(-)
create mode 100644 app/views/errors/greenlight_error.html.erb
delete mode 100644 app/views/errors/internal_error.html.erb
delete mode 100644 app/views/errors/not_found.html.erb
delete mode 100644 app/views/errors/unauthorized.html.erb
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index c5197b97..a8345be2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -111,7 +111,7 @@ class ApplicationController < ActionController::Base
# Manually deal with 401 errors
rescue_from CanCan::AccessDenied do |_exception|
- render "errors/not_found"
+ render "errors/greenlight_error"
end
# Checks to make sure that the admin has changed his password from the default
@@ -141,13 +141,18 @@ class ApplicationController < ActionController::Base
retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
rescue => e
if e.message.eql? "No user with that id exists"
- render "errors/not_found", 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") }
elsif e.message.eql? "Provider not included."
- render "errors/not_found", 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") }
+ elsif e.message.eql? "That user has no configured provider."
+ render "errors/greenlight_error", locals: { status_code: 501,
+ message: I18n.t("errors.no_provider.message"),
+ help: I18n.t("errors.no_provider.help") }
else
- render "errors/internal_error"
+ 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
diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb
index e9131af4..3bea0915 100644
--- a/app/controllers/errors_controller.rb
+++ b/app/controllers/errors_controller.rb
@@ -18,14 +18,21 @@
class ErrorsController < ApplicationController
def not_found
- render status: 404, formats: :html
+ render "greenlight_error", status: 404, formats: :html
end
def internal_error
- render status: 500, formats: :html
+ render "errors/greenlight_error", status: 500, formats: :html,
+ locals: {
+ status_code: 500,
+ message: I18n.t("errors.internal.message"),
+ help: I18n.t("errors.internal.help"),
+ display_back: true
+ }
end
def unauthorized
- render status: 401, formats: :html
+ render "errors/greenlight_error", status: 401, formats: :html, locals: { status_code: 401,
+ message: I18n.t("errors.unauthorized.message"), help: I18n.t("errors.unauthorized.help"), display_back: true }
end
end
diff --git a/app/views/errors/greenlight_error.html.erb b/app/views/errors/greenlight_error.html.erb
new file mode 100644
index 00000000..c7c83e74
--- /dev/null
+++ b/app/views/errors/greenlight_error.html.erb
@@ -0,0 +1,39 @@
+<%
+# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
+# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
+# This program is free software; you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free Software
+# Foundation; either version 3.0 of the License, or (at your option) any later
+# version.
+#
+# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+# You should have received a copy of the GNU Lesser General Public License along
+# with BigBlueButton; if not, see
<%= help %>
+ <% if defined?(display_back) && display_back %> + + <%= t("go_back") %> + + <% end %> + <% else %> +<%= t("errors.not_found.help") %>
+ + <%= t("go_back") %> + + <% end %> +<%= t("errors.internal.help") %>
- - <%= t("go_back") %> - -<%= help %>
- <% else %> -<%= t("errors.not_found.help") %>
- - <%= t("go_back") %> - - <% end %> -<%= t("errors.unauthorized.help") %>
-