From 570b12a903cb226069e3468be4fe24809c11c7a6 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Wed, 27 May 2020 20:10:01 +0300 Subject: [PATCH] FEATURE: Show a detailed 404 page for private topics (#9894) --- app/controllers/application_controller.rb | 20 ++++++++++++++------ config/locales/server.en.yml | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a0f0a566305..e7f8c9750b0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -245,12 +245,20 @@ class ApplicationController < ActionController::Base end end - message = opts[:custom_message_translated] || I18n.t(opts[:custom_message] || type) - error_page_opts = { - title: opts[:custom_message_translated] || I18n.t(opts[:custom_message] || "page_not_found.title"), - status: status_code, - group: opts[:group] - } + if opts[:custom_message_translated] + title = message = opts[:custom_message_translated] + elsif opts[:custom_message] + title = message = I18n.t(opts[:custom_message]) + else + message = I18n.t(type) + if status_code == 403 + title = I18n.t("page_forbidden.title") + else + title = I18n.t("page_not_found.title") + end + end + + error_page_opts = { title: title, status: status_code, group: opts[:group] } if show_json_errors opts = { type: type, status: status_code } diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index c62622dbb9c..ee1d6dde677 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3738,6 +3738,9 @@ en: If this was not you, please [review your existing sessions](%{base_url}/my/preferences/account) and consider changing your password. + page_forbidden: + title: "Oops! That page is private." + page_not_found: title: "Oops! That page doesn’t exist or is private." popular_topics: "Popular"