Skip to content

Commit

Permalink
fixed bug adding mpsk clients
Browse files Browse the repository at this point in the history
fixed a bug resulting in unable to add mpsk clients
  • Loading branch information
agmes4 committed Jan 18, 2025
1 parent d219f2f commit 63156e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions sipa/blueprints/usersuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
TerminationNotPossible,
UnknownError,
ContinuationNotPossible,
SubnetFull,
SubnetFull, MaximumNumberMPSKClients, NoWiFiPasswordGenerated,
)
from sipa.model.misc import PaymentDetails

Expand Down Expand Up @@ -467,7 +467,12 @@ def add_mpsk():
except MacAlreadyExists:
flash(gettext("MAC-Adresse ist bereits in Verwendung!"), "error")
except ValueError:
flash(gettext("Maximale Anzahl von MPSK Clients erreicht!"), "error")
flash(gettext("Invalide Mac Adresse!"), "error")
except MaximumNumberMPSKClients:
flash(gettext("Maximale anzahl an MPSK Clients bereits erstellt!"), "error")
except NoWiFiPasswordGenerated:
flash(gettext("Bevor MPSK Clients angelegt werden können muss ein WiFi Passwort erstellt werden!"), "error")

else:
logger.info('Successfully changed MAC address',
extra={'data': {'mac': mac},
Expand Down
3 changes: 1 addition & 2 deletions sipa/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,9 @@ class MPSKClientForm(FlaskForm):
require_unicast_mac],
description="XX:XX:XX:XX:XX:XX")
name = StringField(
label=lazy_gettext("Neuer Gerätename (Optional)"),
label=lazy_gettext("Neuer Gerätename"),
validators=[Regexp(regex="^[a-zA-Z0-9 ]+",
message=lazy_gettext("Gerätename ist ungültig")),
Optional(),
Length(-1, 30, lazy_gettext("Gerätename zu lang"))],
description=lazy_gettext("TL-WR841N, MacBook, FritzBox, PC, Laptop, o.Ä."),
)
Expand Down
3 changes: 3 additions & 0 deletions sipa/model/pycroft/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def change_mac(self, user_id, password, interface_id, new_mac, host_name):
return self.post(f'user/{user_id}/change-mac/{interface_id}',
data={'password': password, 'mac': new_mac, 'host_name': host_name})

def get_mpsk_clients(self, user_id):
return self.get(f'user/{user_id}/get-mpsks',)

def add_mpsk(self, user_id, password, name, mac):
return self.post(f'user/{user_id}/add-mpsk', data={'password': password, 'name': name, 'mac': mac})

Expand Down

0 comments on commit 63156e2

Please sign in to comment.