FIX: Allow only groups with flairs to be selected (#13744)

It used the same permission check as for primary groups which is
wrong because not all groups that can be primary have a flair.
This commit is contained in:
Bianca Nenciu
2021-07-21 14:41:04 +03:00
committed by GitHub
parent d9faae483d
commit 4da0a33524
3 changed files with 34 additions and 1 deletions

View File

@@ -323,6 +323,12 @@ class Guardian
(group ? !group.automatic : false)
end
def can_use_flair_group?(user, group_id = nil)
return false if !user || !group_id || !user.group_ids.include?(group_id.to_i)
flair_icon, flair_upload_id = Group.where(id: group_id.to_i).pluck_first(:flair_icon, :flair_upload_id)
flair_icon.present? || flair_upload_id.present?
end
def can_change_primary_group?(user)
user && is_staff?
end