From 221fae5875261d1c13df6fa72abd7adab42b1974 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Fri, 8 Jun 2018 16:34:15 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E6=97=A5=E6=9C=9F=E6=88=AA=E6=AD=A2=E5=90=8E?= =?UTF-8?q?=E8=BF=98=E5=8F=AF=E7=99=BB=E5=BD=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/forms.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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()