mailboxes fix enable and disable user

This commit is contained in:
Jorge Pastor 2024-08-07 11:13:19 +02:00
parent b11ebc5d99
commit 081b094a3d
1 changed files with 7 additions and 1 deletions

View File

@ -84,6 +84,11 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
--home %(home)s \\ --home %(home)s \\
--password '%(password)s' --password '%(password)s'
fi fi
if [[ "%(is_active)s" == "True" ]]; then
usermod --unlock %(user)s
else
usermod --lock %(user)s
fi
mkdir -p %(home)s mkdir -p %(home)s
chmod 751 %(home)s chmod 751 %(home)s
chown %(user)s:%(group)s %(home)s""") % context chown %(user)s:%(group)s %(home)s""") % context
@ -146,12 +151,13 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
'user': mailbox.name, 'user': mailbox.name,
'group': mailbox.name, 'group': mailbox.name,
'name': mailbox.name, 'name': mailbox.name,
'password': mailbox.password if mailbox.active else '*%s' % mailbox.password, 'password': mailbox.password,
'home': mailbox.get_home(), 'home': mailbox.get_home(),
'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, 'changepass': changepass,
'is_active': mailbox.active,
} }
context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context
return context return context