Projet

Général

Profil

0001-authenticators-delete-test-cookie-when-authenticatio.patch

Benjamin Dauvergne, 01 juin 2020 14:45

Télécharger (2,31 ko)

Voir les différences:

Subject: [PATCH] authenticators: delete test cookie when authentication is
 successful (#43473)

 src/authentic2/authenticators.py | 4 +++-
 src/authentic2/utils/views.py    | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
src/authentic2/authenticators.py
119 119
        is_secure = request.is_secure
120 120
        context['submit_name'] = self.submit_name
121 121
        if is_post:
122
            test_cookie_check(request)
122
            test_cookie_check(request, delete=False)
123 123
            utils.csrf_token_check(request, form)
124 124
            if form.is_valid():
125 125
                if is_secure:
......
133 133
                                       service_slug=service_slug)
134 134
                if 'ou' in form.fields:
135 135
                    utils.prepend_remember_cookie(request, response, 'preferred-ous', form.cleaned_data['ou'].pk)
136

  
137
                request.session.delete_test_cookie()
136 138
                return response
137 139
        context['form'] = form
138 140
        return render(request, 'authentic2/login_password_form.html', context)
src/authentic2/utils/views.py
18 18
from django.utils.translation import gettext as _
19 19

  
20 20

  
21
def test_cookie_check(request):
21
def test_cookie_check(request, delete=True):
22 22
    '''Verify the test cookie is set, if not log a message for the user explaining the problem.
23 23

  
24 24
       It should only be used in views in which we are sure of coming from the login page.
......
30 30
            request,
31 31
            _('Cookies are disabled in your browser, please activate them or you will not be able to log in.'))
32 32
    else:
33
        request.session.delete_test_cookie()
33
        if delete:
34
            request.session.delete_test_cookie()
34
-