From 1794ec9febf355df89313c3e1942d6f3c236b9e2 Mon Sep 17 00:00:00 2001 From: Spitap Date: Fri, 1 Sep 2023 13:31:30 +0200 Subject: [PATCH 01/10] Fixed pdfcrendtials preventing login --- modoboa/pdfcredentials/handlers.py | 11 +++++++++- modoboa/pdfcredentials/lib.py | 32 +++++++++++++++++++----------- pyproject.toml | 7 ++++--- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/modoboa/pdfcredentials/handlers.py b/modoboa/pdfcredentials/handlers.py index ba8e1ae53..72852fcc9 100644 --- a/modoboa/pdfcredentials/handlers.py +++ b/modoboa/pdfcredentials/handlers.py @@ -1,5 +1,6 @@ """PDF credentials handlers.""" +import logging import os from django.urls import reverse @@ -10,6 +11,7 @@ from django.utils.translation import gettext as _ from modoboa.admin import signals as admin_signals from modoboa.core import models as core_models from modoboa.core import signals as core_signals +from modoboa.lib.exceptions import InternalError from modoboa.parameters import tools as param_tools from .documents import credentials @@ -25,7 +27,14 @@ def password_updated(sender, account, password, created, **kwargs): "generate_at_creation") if (generate_at_creation and not created) or account.is_superuser: return - init_storage_dir() + try: + init_storage_dir() + except InternalError as e: + logger = logging.getLogger("modoboa.admin") + logger.error( + _("Failed to create PDF_credentials directory. " + "Please check the permissions or the path."), + exc_info=e) credentials(account, password) diff --git a/modoboa/pdfcredentials/lib.py b/modoboa/pdfcredentials/lib.py index 363703855..cfe5200c5 100644 --- a/modoboa/pdfcredentials/lib.py +++ b/modoboa/pdfcredentials/lib.py @@ -1,6 +1,7 @@ """Internal library.""" from io import BytesIO +import logging import os import struct @@ -18,7 +19,7 @@ from modoboa.parameters import tools as param_tools def init_storage_dir(): - """Create the directory whare documents will be stored.""" + """Create the directory where documents will be stored.""" storage_dir = param_tools.get_global_parameter("storage_dir") if os.path.exists(storage_dir) and os.access(storage_dir, os.W_OK): return @@ -66,17 +67,24 @@ def crypt_and_save_to_file(content, filename, length, chunksize=64*512): iv = os.urandom(16) cipher = _get_cipher(iv) encryptor = cipher.encryptor() - with open(filename, "wb") as fp: - fp.write(struct.pack(b" Date: Fri, 1 Sep 2023 13:31:49 +0200 Subject: [PATCH 02/10] Fixed message_limit issue on domains --- .../components/domains/DomainCreationForm.vue | 2 +- frontend/src/components/domains/DomainForm.vue | 8 ++++---- .../domains/DomainLimitationsForm.vue | 18 +++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/domains/DomainCreationForm.vue b/frontend/src/components/domains/DomainCreationForm.vue index f2b4679f2..ebcf375ef 100644 --- a/frontend/src/components/domains/DomainCreationForm.vue +++ b/frontend/src/components/domains/DomainCreationForm.vue @@ -92,7 +92,7 @@ export default { items: [ { key: this.$gettext('Quota'), value: this.domain.quota }, { key: this.$gettext('Default mailbox quota'), value: this.domain.default_mailbox_quota }, - { key: this.$gettext('Message sending limit'), value: this.domain.message_sending_limit } + { key: this.$gettext('Message sending limit'), value: this.domain.message_limit } ] } ] diff --git a/frontend/src/components/domains/DomainForm.vue b/frontend/src/components/domains/DomainForm.vue index 35f4156ac..8f53b75b3 100644 --- a/frontend/src/components/domains/DomainForm.vue +++ b/frontend/src/components/domains/DomainForm.vue @@ -89,8 +89,8 @@ Quota: {{ domain.quota }} - - Sending limit: {{ domain.message_sending_limit }} + + Sending limit: {{ domain.message_limit }} No sending limit @@ -207,7 +207,7 @@ export default { } this.working = true try { - const data = { ...this.editedDomain } + const data = JSON.parse(JSON.stringify(this.editedDomain)) if (data.transport === null) { delete data.transport } @@ -231,7 +231,7 @@ export default { domain: { handler: function (val) { if (val) { - this.editedDomain = JSON.parse(JSON.stringify(val)) + this.editedDomain = { ...val } } }, immediate: true diff --git a/frontend/src/components/domains/DomainLimitationsForm.vue b/frontend/src/components/domains/DomainLimitationsForm.vue index ba4b23e16..82ce575cd 100644 --- a/frontend/src/components/domains/DomainLimitationsForm.vue +++ b/frontend/src/components/domains/DomainLimitationsForm.vue @@ -38,7 +38,7 @@ :label="'Message sending limit' | translate" :hint="'Number of messages this domain can send per day. Leave empty for no limit.' | translate" persistent-hint - v-model="form.message_sending_limit" + v-model="form.message_limit" :error-messages="errors" outlined @input="update" @@ -49,9 +49,7 @@