From ac2209d5ad9225576b63f534dcc150b72d6a1255 Mon Sep 17 00:00:00 2001 From: nisha-shaikh Date: Mon, 22 Jul 2024 21:24:46 +0500 Subject: [PATCH] AO3-6709 use i18n standard for admin only access denied error messages --- app/controllers/application_controller.rb | 6 +++--- config/locales/controllers/en.yml | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8c90db669cf..36083115d11 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -269,15 +269,15 @@ def access_denied(options ={}) def admin_only_access_denied respond_to do |format| format.html do - flash[:error] = ts("Sorry, only an authorized admin can access the page you were trying to reach.") + flash[:error] = t("admin.access.page_access_denied") redirect_to root_path end format.json do - errors = [ts("Sorry, only an authorized admin can do that.")] + errors = [t("admin.access.action_access_denied")] render json: { errors: errors }, status: :forbidden end format.js do - flash[:error] = ts("Sorry, only an authorized admin can access the page you were trying to reach.") + flash[:error] = t("admin.access.page_access_denied") render js: "window.location.href = '#{root_path}';" end end diff --git a/config/locales/controllers/en.yml b/config/locales/controllers/en.yml index 354b593554b..127682d5e89 100644 --- a/config/locales/controllers/en.yml +++ b/config/locales/controllers/en.yml @@ -8,6 +8,9 @@ en: success: one: "%{count} person from the invite queue is being invited." other: "%{count} people from the invite queue are being invited." + access: + page_access_denied: Sorry, only an authorized admin can access the page you were trying to reach. + action_access_denied: Sorry, only an authorized admin can do that. blocked: users: create: