From 10dc7a86a8f0a0ad1568408d91bd9de0d00fd564 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 Jan 2025 13:26:25 +0100 Subject: [PATCH] fixed delete mpsk its checked rather the to delete mpsk client exists for the user refactoring changed the changing for the sample backends changing mpsk --- sipa/blueprints/usersuite.py | 5 +++-- sipa/model/sample/user.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sipa/blueprints/usersuite.py b/sipa/blueprints/usersuite.py index db76b993..cdfde400 100644 --- a/sipa/blueprints/usersuite.py +++ b/sipa/blueprints/usersuite.py @@ -422,7 +422,7 @@ def change_mpsk(mpsk_id: int): capability_or_403('mpsk_clients', 'edit') form = MPSKClientForm() - + mpsk_client = get_mpsk_client_or_404(mpsk_id) if form.validate_on_submit(): password = form.password.data mac = form.mac.data @@ -451,7 +451,7 @@ def change_mpsk(mpsk_id: int): ) return redirect(url_for(".view_mpsk")) - mpsk_client = get_mpsk_client_or_404(mpsk_id) + form.mac.data = mpsk_client.mac form.name.data = mpsk_client.name @@ -515,6 +515,7 @@ def add_mpsk(): def delete_mpsk(mpsk_id: int): capability_or_403('mpsk_clients', 'edit') + get_mpsk_client_or_404(mpsk_id) form = DeleteMPSKClientForm() if form.validate_on_submit(): diff --git a/sipa/model/sample/user.py b/sipa/model/sample/user.py index 012fe3bd..16a40ee1 100644 --- a/sipa/model/sample/user.py +++ b/sipa/model/sample/user.py @@ -172,8 +172,9 @@ def mpsk_clients(self, value): def change_mpsk_clients(self, mac, name, mpsk_id, password: str): if mpsk_id in range(len(self.config["mpsk_clients"])): - self.config["mpsk_clients"][mpsk_id].name = name - self.config["mpsk_clients"][mpsk_id].mac = mac + self.config["mpsk_clients"][mpsk_id] = MPSKClientEntry( + name=name, id=mpsk_id, mac=mac + ) else: raise ValueError(f"mac: {mac} not found for user")