Skip to content

Commit 0d7a5dd

Browse files
fix(tags): defer policy if min primary & secondary tags 0
Deferring it rather then force allowing in that case allows other policies to take action. Consider this more of a POC
1 parent 097b3c5 commit 0d7a5dd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

extensions/tags/src/Access/GlobalPolicy.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function can(User $actor, string $ability)
4242
return $this->allow();
4343
}
4444

45+
if ($ability === 'startDiscussion') {
46+
$minPrimaryTags = (int) $this->settings->get('flarum-tags.min_primary_tags');
47+
$minSecondaryTags = (int) $this->settings->get('flarum-tags.min_secondary_tags');
48+
49+
if (($minPrimaryTags === 0 && $minSecondaryTags === 0)) {
50+
return;
51+
}
52+
}
53+
4554
if (in_array($ability, ['viewForum', 'startDiscussion'])) {
4655
if (! isset($enoughPrimary[$actor->id][$ability])) {
4756
$primaryTagsWhereNeedsPermission = $this->settings->get('flarum-tags.min_primary_tags');

0 commit comments

Comments
 (0)