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