mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
When enabling/disabling Django user, also enable/disable the corresponding POSIX user.
This commit is contained in:
1 parent
eeced1c213
commit
45b5ce8de9
4 files changed
+75
-11
No files matched your search
@@ -16,6 +16,7 @@
|
||||
#
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.forms import UserCreationForm, SetPasswordForm
|
||||
from gettext import gettext as _
|
||||
|
||||
@@ -41,6 +42,26 @@ class CreateUserForm(UserCreationForm):
|
||||
return user
|
||||
|
||||
|
||||
class UserUpdateForm(forms.ModelForm):
|
||||
"""When user is enabled/disabled, also enables/disables the POSIX user."""
|
||||
|
||||
class Meta:
|
||||
fields = ('username', 'groups', 'is_active')
|
||||
model = User
|
||||
widgets = {
|
||||
'groups': forms.widgets.CheckboxSelectMultiple(),
|
||||
}
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super(UserUpdateForm, self).save(commit)
|
||||
if commit:
|
||||
if user.is_active:
|
||||
actions.superuser_run('enable-user', [user.username])
|
||||
else:
|
||||
actions.superuser_run('disable-user', [user.username])
|
||||
return user
|
||||
|
||||
|
||||
class UserChangePasswordForm(SetPasswordForm):
|
||||
"""Custom form that also updates password for POSIX users."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user