mailbox not change pass on single reload
This commit is contained in:
parent
80aeb8ebe2
commit
17757800b8
|
@ -213,6 +213,8 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo
|
|||
old = Mailbox.objects.get(pk=obj.pk)
|
||||
if old.custom_filtering != obj.custom_filtering:
|
||||
messages.warning(request, msg)
|
||||
# pass var to the backend so you don't change the password
|
||||
obj.changepass = None
|
||||
elif obj.custom_filtering:
|
||||
messages.warning(request, msg)
|
||||
super(MailboxAdmin, self).save_model(request, obj, form, change)
|
||||
|
|
|
@ -69,6 +69,7 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
|
|||
self.append(textwrap.dedent("""
|
||||
# Update/create %(user)s user state
|
||||
if id %(user)s ; then
|
||||
if [[ "%(changepass)s" == "True" ]]; then
|
||||
old_password=$(getent shadow %(user)s | cut -d':' -f2)
|
||||
usermod %(user)s \\
|
||||
--shell %(initial_shell)s \\
|
||||
|
@ -77,6 +78,7 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
|
|||
# Postfix SASL caches passwords
|
||||
RESTART_POSTFIX=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
useradd %(user)s \\
|
||||
--home %(home)s \\
|
||||
|
@ -135,6 +137,11 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
|
|||
super().commit()
|
||||
|
||||
def get_context(self, mailbox):
|
||||
# Check if you have to change password
|
||||
try:
|
||||
changepass = mailbox.changepass
|
||||
except:
|
||||
changepass = True
|
||||
context = {
|
||||
'user': mailbox.name,
|
||||
'group': mailbox.name,
|
||||
|
@ -144,6 +151,7 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
|
|||
'maildir': os.path.join(mailbox.get_home(), 'Maildir'),
|
||||
'initial_shell': self.SHELL,
|
||||
'banner': self.get_banner(),
|
||||
'changepass': changepass,
|
||||
}
|
||||
context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context
|
||||
return context
|
||||
|
|
Loading…
Reference in a new issue