Skip to content

Commit

Permalink
fixed sending mpsk clients when loading user data
Browse files Browse the repository at this point in the history
until now the mpsk clients would not been send when loading a user via the API
  • Loading branch information
agmes4 committed Jan 18, 2025
1 parent c44f543 commit 70d555f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions web/api/v0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ class _Entry(t.TypedDict):
med = scheduled_membership_end(user)
mbd = scheduled_membership_start(user)

interface_info = [{
'id': i.id,
'mac': str(i.mac),
'ips': [str(ip.address) for ip in i.ips]
} for h in user.hosts for i in h.interfaces]

interface_info = [

Check warning on line 166 in web/api/v0/__init__.py

View check run for this annotation

Codecov / codecov/patch

web/api/v0/__init__.py#L166

Added line #L166 was not covered by tests
{"id": i.id, "mac": str(i.mac), "ips": [str(ip.address) for ip in i.ips]}
for h in user.hosts
for i in h.interfaces
]
mpsk_clients = [

Check warning on line 171 in web/api/v0/__init__.py

View check run for this annotation

Codecov / codecov/patch

web/api/v0/__init__.py#L171

Added line #L171 was not covered by tests
{"id": mpsk.id, "mac": str(mpsk.mac), "name": mpsk.name} for mpsk in user.mpsk_clients
]
return jsonify(
id=user.id,
user_id=encode_type2_user_id(user.id),
Expand Down Expand Up @@ -198,6 +200,7 @@ class _Entry(t.TypedDict):
membership_begin_date=mbd.isoformat() if mbd else None,
wifi_password=wifi_password,
birthdate=user.birthdate.isoformat() if user.birthdate else None,
mpsk_clients=mpsk_clients,
)


Expand All @@ -211,6 +214,7 @@ def get(self, user_id: int) -> Response:
.joinedload(Host.interfaces)
.joinedload(Interface.ips),
undefer(User.wifi_passwd_hash),
selectinload(User.mpsk_clients),
joinedload(User.account)
.selectinload(Account.splits)
.joinedload(Split.transaction),
Expand Down

0 comments on commit 70d555f

Please sign in to comment.