Project

General

Profile

0001-prefill-username-when-authenticated-28853.patch

Benjamin Dauvergne, 18 Jun 2019 12:05 PM

Download (1.21 KB)

View differences:

Subject: [PATCH 1/2] prefill username when authenticated (#28853)

 src/authentic2/authenticators.py | 4 ++++
 1 file changed, 4 insertions(+)
src/authentic2/authenticators.py
38 38
        is_post = request.method == 'POST' and self.submit_name in request.POST
39 39
        data = request.POST if is_post else None
40 40
        form = authentication_forms.AuthenticationForm(request=request, data=data)
41
        if request.user.is_authenticated():
42
            form.initial['username'] = request.user.username or request.user.email
43
            form.fields['username'].widget.attrs.pop('autofocus', None)
44
            form.fields['password'].widget.attrs['autofocus'] = 'autofocus'
41 45
        if app_settings.A2_ACCEPT_EMAIL_AUTHENTICATION:
42 46
            form.fields['username'].label = _('Username or email')
43 47
        if app_settings.A2_USERNAME_LABEL:
44
-