diff --git a/plinth/modules/sso/forms.py b/plinth/modules/sso/forms.py index 3c9dd9968..e490bfbd1 100644 --- a/plinth/modules/sso/forms.py +++ b/plinth/modules/sso/forms.py @@ -24,9 +24,17 @@ from django.contrib.auth.forms import \ class AuthenticationForm(DjangoAuthenticationForm): - """Authentication form with an additional Captcha field.""" - captcha = CaptchaField() + """Authentication form with an additional username field attributes.""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'}) + self.fields['username'].widget.attrs.update({ + 'autofocus': 'autofocus', + 'autocapitalize': 'none', + 'autocomplete': 'username' + }) + + +class CaptchaAuthenticationForm(AuthenticationForm): + """Authentication form with an additional Captcha field.""" + captcha = CaptchaField() diff --git a/plinth/modules/sso/views.py b/plinth/modules/sso/views.py index 7991a0581..dda518f9b 100644 --- a/plinth/modules/sso/views.py +++ b/plinth/modules/sso/views.py @@ -27,10 +27,9 @@ from axes.decorators import axes_form_invalid from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.views import LoginView, LogoutView from django.http import HttpResponseRedirect - from plinth import actions, utils, web_framework -from .forms import AuthenticationForm +from .forms import AuthenticationForm, CaptchaAuthenticationForm PRIVATE_KEY_FILE_NAME = 'privkey.pem' SSO_COOKIE_NAME = 'auth_pubtkt' @@ -61,6 +60,7 @@ class SSOLoginView(LoginView): """ redirect_authenticated_user = True template_name = 'login.html' + form_class = AuthenticationForm def dispatch(self, request, *args, **kwargs): response = super(SSOLoginView, self).dispatch(request, *args, **kwargs) @@ -79,11 +79,11 @@ class SSOLoginView(LoginView): class CaptchaLoginView(LoginView): redirect_authenticated_user = True template_name = 'login.html' - form_class = AuthenticationForm + form_class = CaptchaAuthenticationForm def dispatch(self, request, *args, **kwargs): - response = super(CaptchaLoginView, - self).dispatch(request, *args, **kwargs) + response = super(CaptchaLoginView, self).dispatch( + request, *args, **kwargs) if not request.POST: return response diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py index 1c13f497f..874ccb526 100644 --- a/plinth/modules/users/forms.py +++ b/plinth/modules/users/forms.py @@ -125,7 +125,11 @@ class CreateUserForm(ValidNewUsernameCheckMixin, self.request = request super(CreateUserForm, self).__init__(*args, **kwargs) self.fields['groups'].choices = get_group_choices() - self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'}) + self.fields['username'].widget.attrs.update({ + 'autofocus': 'autofocus', + 'autocapitalize': 'none', + 'autocomplete': 'username' + }) def save(self, commit=True): """Save the user model and create LDAP user if required.""" @@ -194,7 +198,11 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, self.username = username super(UserUpdateForm, self).__init__(*args, **kwargs) self.is_last_admin_user = get_last_admin_user() == self.username - self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'}) + self.fields['username'].widget.attrs.update({ + 'autofocus': 'autofocus', + 'autocapitalize': 'none', + 'autocomplete': 'username' + }) choices = []