Skip to content

A platform for community discussion. Free, open, simple.

DEV: Better error message when user is not allowed to user tags (#26380)

Osama Sayegh0b34b4cbe950
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 03beae8f3a0..cbae02e8f2b 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -5160,6 +5160,7 @@ en:
limited_to_one_tag_from_group: "The tags %{tags} cannot be used simultaneously. Please include only one of them."
invalid_target_tag: "cannot be a synonym of a synonym"
synonyms_exist: "is not allowed while synonyms exist"
+ user_not_permitted: "You're not allowed to tag topics"
rss_by_tag: "Topics tagged %{tag}"
finish_installation:
diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rb
index a964a8a22a0..a8d40c731ff 100644
--- a/lib/discourse_tagging.rb
+++ b/lib/discourse_tagging.rb
@@ -214,9 +214,11 @@ module DiscourseTagging
new_tag_names: topic.tags.map(&:name),
)
- return true
+ true
+ else
+ topic.errors.add(:base, I18n.t("tags.user_not_permitted"))
+ false
end
- false
end
def self.validate_category_tags(guardian, model, category, tags = [])