diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c8943667..70df16a3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -141,7 +141,11 @@ 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: { user_not_found: true } + render "errors/not_found", 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"), + help: I18n.t("errors.not_found.user_missing.help") } else render "errors/internal_error" end diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 5c388a4e..e9131af4 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -21,10 +21,6 @@ class ErrorsController < ApplicationController render status: 404, formats: :html end - def unprocessable - render status: 422, formats: :html - end - def internal_error render status: 500, formats: :html end diff --git a/app/views/errors/bigbluebutton_error.html.erb b/app/views/errors/bigbluebutton_error.html.erb index b1e41b6b..f30cdd8e 100644 --- a/app/views/errors/bigbluebutton_error.html.erb +++ b/app/views/errors/bigbluebutton_error.html.erb @@ -14,7 +14,7 @@ %>
-
<%= I18n.t("errors.bigbluebutton.title") %>
-

<%= I18n.t("errors.bigbluebutton.message") %>

-

<%= I18n.t("errors.bigbluebutton.help", doc_link: "http://docs.bigbluebutton.org/greenlight/gl-install.html#setting-bigbluebutton-credentials").html_safe %>

+
<%= t("errors.bigbluebutton.title") %>
+

<%= t("errors.bigbluebutton.message") %>

+

<%= t("errors.bigbluebutton.help", doc_link: "http://docs.bigbluebutton.org/greenlight/gl-install.html#setting-bigbluebutton-credentials").html_safe %>

diff --git a/app/views/errors/internal_error.html.erb b/app/views/errors/internal_error.html.erb index af926b5b..0c76f1db 100644 --- a/app/views/errors/internal_error.html.erb +++ b/app/views/errors/internal_error.html.erb @@ -14,7 +14,7 @@ %>
-
500
+
500

<%= t("errors.internal.message") %>

<%= t("errors.internal.help") %>

diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index 95bdcbbb..d259ceac 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -14,10 +14,10 @@ %>
-
404
- <% if defined?(user_not_found) %> -

<%= t("errors.not_found.user_message") %>

-

<%= t("errors.not_found.user_help") %>

+
404
+ <% if defined?(message) && defined?(help) %> +

<%= message %>

+

<%= help %>

<% else %>

<%= t("errors.not_found.message") %>

<%= t("errors.not_found.help") %>

diff --git a/app/views/errors/unauthorized.html.erb b/app/views/errors/unauthorized.html.erb index 1e6682a8..23dcdd7d 100644 --- a/app/views/errors/unauthorized.html.erb +++ b/app/views/errors/unauthorized.html.erb @@ -14,7 +14,7 @@ %>
-
401
-

<%= I18n.t("errors.unauthorized.message") %>

-

<%= I18n.t("errors.unauthorized.help") %>

+
401
+

<%= t("errors.unauthorized.message") %>

+

<%= t("errors.unauthorized.help") %>

diff --git a/app/views/errors/unprocessable.html.erb b/app/views/errors/unprocessable.html.erb deleted file mode 100644 index cec62f44..00000000 --- a/app/views/errors/unprocessable.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<% -# 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 . -%> - -
diff --git a/config/locales/en.yml b/config/locales/en.yml index fe338331..9082984e 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -119,7 +119,7 @@ en: message: Invalid BigBlueButton Endpoint and Secret title: Server Error internal: - message: Oh no! Looks like something went wrong on our end. + message: Looks like something went wrong on our end. help: The error has been logged, we'll take a look! migration_error: contact_admin: If you are not an administrator, please contact one. @@ -138,17 +138,18 @@ en: confirmation: doesn't match %{attribute} inclusion: is not included in the list not_found: - message: Whoops! Looks like we can't find that. + message: Sorry! The page you are looking for does not exist. help: Is it possible its been removed? - user_message: User Not Found. - user_help: Sorry, this user is not registered. + user_not_found: + help: Please contact an administrator. + message: Sorry, this user is not registered. + user_missing: + help: Please verify the URL and try again + message: The URL that you have entered is not valid. title: Errors unauthorized: message: You do not have access to this application help: If you believe this is a mistake, please contact your system administrator. - unprocessable: - message: Oops! Request is unprocessable. - help: Unfortunately this isn't a valid request. expired_reset_token: Password reset link has expired! features: title: Features diff --git a/config/routes.rb b/config/routes.rb index e0429db7..a1dc1eaa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,7 +22,6 @@ Rails.application.routes.draw do # Error routes. match '/401', to: 'errors#unauthorized', via: :all, as: :unauthorized match '/404', to: 'errors#not_found', via: :all, as: :not_found - match '/422', to: 'errors#unprocessable', via: :all match '/500', to: 'errors#internal_error', via: :all, as: :internal_error # Signin/Signup routes. diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 14bf1f65..f8f8a917 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -74,7 +74,7 @@ describe ApplicationController do it "renders a 404 error if user is not found" do allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true) allow(Rails.env).to receive(:test?).and_return(false) - allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("") + allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("fake_provider") allow_any_instance_of(BbbApi).to receive(:retrieve_provider_info).and_raise("No user with that id exists") routes.draw { get "user_not_found" => "anonymous#user_not_found" } @@ -83,7 +83,19 @@ describe ApplicationController do expect(response).to render_template("errors/not_found") end - it "renders a 500 error if any other error is not found" do + it "renders a 404 error if user is not given" do + allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true) + allow(Rails.env).to receive(:test?).and_return(false) + allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("") + allow_any_instance_of(BbbApi).to receive(:retrieve_provider_info).and_raise("Provider not included.") + + routes.draw { get "user_not_found" => "anonymous#user_not_found" } + + get :user_not_found + expect(response).to render_template("errors/not_found") + end + + it "renders a 500 error if any other error related to bbb api" do allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true) allow(Rails.env).to receive(:test?).and_return(false) allow_any_instance_of(SessionsHelper).to receive(:parse_user_domain).and_return("") diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb index 48616b0a..d346e940 100644 --- a/spec/controllers/errors_controller_spec.rb +++ b/spec/controllers/errors_controller_spec.rb @@ -26,13 +26,6 @@ describe ErrorsController, type: :controller do end end - describe "GET #unprocessable" do - it "returns unprocessable" do - get :unprocessable - expect(response).to have_http_status(422) - end - end - describe "GET #internal_error" do it "returns internal_error" do get :internal_error