Skip to content

Commit

Permalink
Merge pull request #3167 from modoboa/fix/permissive-redis-connection
Browse files Browse the repository at this point in the history
Make password scheme caching more permissive
  • Loading branch information
tonioo committed Feb 2, 2024
2 parents c33234d + 91ff9e2 commit acf9244
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modoboa/core/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from django_rq import get_queue

from redis.exceptions import ConnectionError

from modoboa.core.jobs import job_retrieve_available_hashers
from modoboa.core.password_hashers import get_dovecot_schemes
from modoboa.core.password_hashers.base import PasswordHasher
Expand Down Expand Up @@ -45,11 +47,15 @@ def get_default_password_scheme():


def get_password_scheme():
available_schemes = cache.get("password_scheme_choice")
if available_schemes is None:
get_queue("modoboa").enqueue(job_retrieve_available_hashers)
try:
available_schemes = cache.get("password_scheme_choice")
if available_schemes is None:
get_queue("modoboa").enqueue(job_retrieve_available_hashers)
return get_default_password_scheme()
return available_schemes
except ConnectionError:
# TODO : notification/email to admin
return get_default_password_scheme()
return available_schemes


class GeneralParametersForm(param_forms.AdminParametersForm):
Expand Down

0 comments on commit acf9244

Please sign in to comment.