core: only return group names for user_self
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
cb31e52d0e
commit
c1f302fb7c
|
@ -101,9 +101,14 @@ class UserSelfSerializer(ModelSerializer):
|
||||||
|
|
||||||
is_superuser = BooleanField(read_only=True)
|
is_superuser = BooleanField(read_only=True)
|
||||||
avatar = CharField(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)
|
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:
|
class Meta:
|
||||||
|
|
||||||
model = User
|
model = User
|
||||||
|
|
|
@ -29209,7 +29209,7 @@ components:
|
||||||
groups:
|
groups:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Group'
|
type: string
|
||||||
readOnly: true
|
readOnly: true
|
||||||
email:
|
email:
|
||||||
type: string
|
type: string
|
||||||
|
|
Reference in a new issue