From 081b094a3d8cb9119a399fb214c4161a5c645a4c Mon Sep 17 00:00:00 2001 From: jorgepastorr Date: Wed, 7 Aug 2024 11:13:19 +0200 Subject: [PATCH] mailboxes fix enable and disable user --- orchestra/contrib/mailboxes/backends.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/orchestra/contrib/mailboxes/backends.py b/orchestra/contrib/mailboxes/backends.py index a958ad5a..a5264290 100644 --- a/orchestra/contrib/mailboxes/backends.py +++ b/orchestra/contrib/mailboxes/backends.py @@ -84,6 +84,11 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController): --home %(home)s \\ --password '%(password)s' fi + if [[ "%(is_active)s" == "True" ]]; then + usermod --unlock %(user)s + else + usermod --lock %(user)s + fi mkdir -p %(home)s chmod 751 %(home)s chown %(user)s:%(group)s %(home)s""") % context @@ -146,12 +151,13 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController): 'user': mailbox.name, 'group': mailbox.name, 'name': mailbox.name, - 'password': mailbox.password if mailbox.active else '*%s' % mailbox.password, + 'password': mailbox.password, 'home': mailbox.get_home(), 'maildir': os.path.join(mailbox.get_home(), 'Maildir'), 'initial_shell': self.SHELL, 'banner': self.get_banner(), 'changepass': changepass, + 'is_active': mailbox.active, } context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context return context