1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 18:51:40 +02:00

Implement hidden permission groups (#2129)

Only users that have the new `viewHiddenGroups` permissions will be able to see these groups.

You might want this when you want to give certain users special permissions, but don't want to make your authorization scheme public to regular users.

Co-authored-by: luceos <daniel+github@klabbers.email>
This commit is contained in:
Alexander Skvortsov
2020-04-21 11:49:53 -04:00
committed by GitHub
parent df8f73bd3d
commit 6e8884f190
13 changed files with 130 additions and 7 deletions

View File

@@ -45,6 +45,10 @@ class BasicUserSerializer extends AbstractSerializer
*/
protected function groups($user)
{
return $this->hasMany($user, GroupSerializer::class);
if ($this->getActor()->can('viewHiddenGroups')) {
return $this->hasMany($user, GroupSerializer::class);
}
return $this->hasMany($user, GroupSerializer::class, 'visibleGroups');
}
}