core: only return group names for user_self

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-05 12:31:25 +02:00
parent 4f57dfda93
commit f5761dc70d
2 changed files with 7 additions and 2 deletions

View file

@ -101,9 +101,14 @@ class UserSelfSerializer(ModelSerializer):
is_superuser = BooleanField(read_only=True)
avatar = CharField(read_only=True)
groups = ListSerializer(child=GroupSerializer(), read_only=True, source="ak_groups")
groups = SerializerMethodField()
uid = CharField(read_only=True)
def get_groups(self, user: User) -> list[str]:
"""Return only the group names a user is member of"""
for group in user.ak_groups.all():
yield group.name
class Meta:
model = User

View file

@ -29273,7 +29273,7 @@ components:
groups:
type: array
items:
$ref: '#/components/schemas/Group'
type: string
readOnly: true
email:
type: string