feat(radius): Add the user to the correct group
When generating the first WiFi password, the user is added to the `radius_access` group, which will allow them to connect. This also fix a previous incorrect logic where users without wifi password could not generate one.
This commit is contained in:
parent
f4428ace59
commit
a88d31541c
1 changed files with 5 additions and 2 deletions
|
@ -83,9 +83,12 @@ class GenerateWiFiPasswordView(LoginRequiredMixin, RedirectView):
|
|||
|
||||
if user.kanidm is None:
|
||||
messages.error(self.request, _("Compte DGNum inexistant."))
|
||||
elif not user.kanidm.radius_secret:
|
||||
messages.error(self.request, _("Mot de passe WiFi déjà existant."))
|
||||
else:
|
||||
# Give access to the wifi network when the user creates its first password
|
||||
if not user.kanidm.radius_secret:
|
||||
async_to_sync(klient.group_add_members)(
|
||||
"radius_access", [user.username]
|
||||
)
|
||||
async_to_sync(klient.call_post)(f"/v1/person/{user.username}/_radius")
|
||||
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
|
Loading…
Reference in a new issue