mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
When updating a user's password, also update the POSIX user's password, when needed.
This commit is contained in:
1 parent
46dd2225f7
commit
eeced1c213
3 files changed
+49
-4
No files matched your search
@@ -16,7 +16,7 @@
|
||||
#
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.forms import UserCreationForm, SetPasswordForm
|
||||
from gettext import gettext as _
|
||||
|
||||
from plinth import actions
|
||||
@@ -39,3 +39,15 @@ class CreateUserForm(UserCreationForm):
|
||||
'create-user',
|
||||
[user.username, self.cleaned_data['password1']])
|
||||
return user
|
||||
|
||||
|
||||
class UserChangePasswordForm(SetPasswordForm):
|
||||
"""Custom form that also updates password for POSIX users."""
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super(UserChangePasswordForm, self).save(commit)
|
||||
if commit:
|
||||
actions.superuser_run(
|
||||
'change-user-password',
|
||||
[user.username, self.cleaned_data['new_password1']])
|
||||
return user
|
||||
Reference in new issue
Block a user