diff --git a/apps/users/forms.py b/apps/users/forms.py index 06c544383..165694c3f 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -16,13 +16,14 @@ class UserLoginForm(AuthenticationForm): max_length=128, strip=False ) + def confirm_login_allowed(self, user): + if not user.is_staff: + raise forms.ValidationError( + self.error_messages['inactive'], + code='inactive',) -class UserLoginCaptchaForm(AuthenticationForm): - username = forms.CharField(label=_('Username'), max_length=100) - password = forms.CharField( - label=_('Password'), widget=forms.PasswordInput, - max_length=128, strip=False - ) + +class UserLoginCaptchaForm(UserLoginForm): captcha = CaptchaField() diff --git a/apps/users/views/user.py b/apps/users/views/user.py index 598726fc1..3adb1d156 100644 --- a/apps/users/views/user.py +++ b/apps/users/views/user.py @@ -109,12 +109,13 @@ class UserUpdateView(AdminUserRequiredMixin, SuccessMessageMixin, UpdateView): def form_valid(self, form): password = form.cleaned_data.get('password') - is_ok = check_password_rules(password) - if not is_ok: - form.add_error( - "password", _("* Your password does not meet the requirements") - ) - return self.form_invalid(form) + if password: + is_ok = check_password_rules(password) + if not is_ok: + form.add_error( + "password", _("* Your password does not meet the requirements") + ) + return self.form_invalid(form) return super().form_valid(form) diff --git a/config_example.py b/config_example.py index 45d4b00f3..0c8d87094 100644 --- a/config_example.py +++ b/config_example.py @@ -51,11 +51,6 @@ class Config: REDIS_HOST = '127.0.0.1' REDIS_PORT = 6379 REDIS_PASSWORD = '' - BROKER_URL = 'redis://%(password)s%(host)s:%(port)s/3' % { - 'password': REDIS_PASSWORD, - 'host': REDIS_HOST, - 'port': REDIS_PORT, - } def __init__(self): pass