Projet

Général

Profil

0001-ldap-move-messages-from-hard-coded-to-templates-5129.patch

Loïc Dachary, 19 février 2021 13:55

Télécharger (2,3 ko)

Voir les différences:

Subject: [PATCH] ldap: move messages from hard coded to templates (#51294)

Fixes: #51294

Licenses: MIT
 src/authentic2/backends/ldap_backend.py                     | 6 +++++-
 .../authentic2/ldap_backend/ppolicy_accountLocked.html      | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)
 create mode 100644 src/authentic2/templates/authentic2/ldap_backend/ppolicy_accountLocked.html
src/authentic2/backends/ldap_backend.py
47 47
from django.contrib import messages
48 48
from django.contrib.auth import get_user_model
49 49
from django.contrib.auth.models import Group
50
from django.template import loader
50 51
from django.utils.encoding import force_bytes, force_text
51 52
from django.utils import six
52 53
from django.utils.six.moves.urllib import parse as urlparse
......
242 243

  
243 244
    if ctrl.error:
244 245
        error = ppolicy.PasswordPolicyError.namedValues[ctrl.error]
246
        message_template = loader.get_template('authentic2/ldap_backend/ppolicy_{error}.html'.format(error=error))
247
        if message_template:
248
            message = message_template.render()
245 249
        error2message = {
246 250
            'passwordExpired': _('The password expired'),
247
            'accountLocked': _('The account is locked.'),
251
            'accountLocked': message,
248 252
            'changeAfterReset': _('The password was reset and must be changed.'),
249 253
            'passwordModNotAllowed': _('It is not possible to modify the password.'),
250 254
            'mustSupplyOldPassword': _('The old password must be supplied.'),
src/authentic2/templates/authentic2/ldap_backend/ppolicy_accountLocked.html
1
{% load i18n %}
2
{% blocktrans %}The account is locked.{% endblocktrans %}
0
-