Projet

Général

Profil

0002-auth_fc-show-warning-on-password-change-page-if-user.patch

Benjamin Dauvergne, 22 novembre 2022 21:20

Télécharger (1,94 ko)

Voir les différences:

Subject: [PATCH 2/3] auth_fc: show warning on password change page if user is
 linked to FranceConnect (#69989)

 src/authentic2/views.py        |  1 +
 src/authentic2_auth_fc/apps.py | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
src/authentic2/views.py
1560 1560
        if not utils_misc.user_can_change_password(request=request):
1561 1561
            messages.warning(request, _('Password change is forbidden'))
1562 1562
            return utils_misc.redirect(request, self.post_change_redirect)
1563
        hooks.call_hooks('password_change_view', request=self.request)
1563 1564
        return super().dispatch(request, *args, **kwargs)
1564 1565

  
1565 1566
    def post(self, request, *args, **kwargs):
src/authentic2_auth_fc/apps.py
115 115
        if url:
116 116
            return [url]
117 117
        return []
118

  
119
    def a2_hook_password_change_view(self, request=None, **kwargs):
120
        from django.contrib import messages
121
        from django.utils.translation import gettext as _
122

  
123
        if request and request.user.is_authenticated and request.user.fc_accounts.exists():
124
            messages.warning(
125
                request,
126
                _(
127
                    '''\
128
Watch out, this password is the one from your local account and not the one from the \
129
account used through FranceConnect. It will only be useful when you connect \
130
with locally and not through FranceConnect.'''
131
                ),
132
            )
118
-