Skip to content

Commit

Permalink
Fixed grammatically incorrect message while accessing pages without p…
Browse files Browse the repository at this point in the history
…ermission (#10735)

* Fixed grammatically incorrect message while accessing pages without permissions

* key fix

* key fix #2

* switch -> if else
  • Loading branch information
pranav-027 authored Feb 3, 2025
1 parent b9cc989 commit 64d379f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def doorkeeper_unauthorized_render_options(error: nil)
def redirect_to_root_unless_user(action, *)
redirecting = !current_user&.send(action, *)
if redirecting
flash[:danger] = "You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}"
flash[:danger] = if action == :has_permission?
t("errors.messages.no_permission")
else
"You are not allowed to #{action.to_s.sub(/^can_/, '').chomp('?').humanize.downcase}"
end
redirect_to root_url
end
redirecting
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ en:
wrong_size: "is the wrong size (should be %{file_size})"
size_too_small: "is too small (should be at least %{file_size})"
size_too_big: "is too big (should be at most %{file_size})"
no_permission: "You do not have the required permissions to access this page."
devise:
#context: Overridden key for sign in
passwords:
Expand Down

0 comments on commit 64d379f

Please sign in to comment.