Skip to content

Commit

Permalink
fixed delete mpsk
Browse files Browse the repository at this point in the history
its checked rather the to delete mpsk client exists for the user
refactoring
changed the changing for the sample backends changing mpsk
  • Loading branch information
agmes4 committed Jan 19, 2025
1 parent 3cba263 commit 10dc7a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sipa/blueprints/usersuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand Down
5 changes: 3 additions & 2 deletions sipa/model/sample/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 10dc7a8

Please sign in to comment.