Projet

Général

Profil

0001-WIP-send-notification-emails-for-unauthorized-passwo.patch

Paul Marillonnet, 22 décembre 2017 14:45

Télécharger (1,97 ko)

Voir les différences:

Subject: [PATCH] WIP send notification emails for unauthorized password reset
 requests (#20830)

 src/authentic2/profile_forms.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
src/authentic2/profile_forms.py
5 5
from django.contrib.auth import get_user_model
6 6

  
7 7
from .backends import get_user_queryset
8
from .utils import send_password_reset_mail
8
from .utils import send_password_reset_mail, send_templated_mail
9 9
from . import hooks, app_settings
10 10

  
11 11

  
......
26 26
        email = self.cleaned_data["email"].strip()
27 27
        users = get_user_queryset()
28 28
        active_users = users.filter(email__iexact=email, is_active=True)
29
        inactive_users = users.filter(email__iexact=email, is_active=False)
29 30
        for user in active_users:
30 31
            # we don't set the password to a random string, as some users should not have
31 32
            # a password
......
33 34
                                   and app_settings.A2_SET_RANDOM_PASSWORD_ON_RESET)
34 35
            send_password_reset_mail(user, set_random_password=set_random_password,
35 36
                                     next_url=self.cleaned_data.get('next_url'))
36
        if not active_users:
37
        for user in inactive_users:
38
            send_templated_mail(user_or_email=user, template_names="registration/password_reset_refused")
39

  
40
        if not active_users and not inactive_users:
37 41
            logger.info(u'password reset requests for "%s", no user found')
38 42
        hooks.call_hooks('event', name='password-reset', email=email, users=active_users)
39
-