瀏覽代碼

BugFix: Login with non existing user

master
Dirk Alders 4 天之前
父節點
當前提交
b63cfaa741
共有 1 個檔案被更改,包括 7 行新增2 行删除
  1. 7
    2
      views.py

+ 7
- 2
views.py 查看文件

@@ -108,8 +108,13 @@ def login(request):
108 108
             return redirect(request.GET.get('next') or '/')
109 109
         else:
110 110
             username = form.cleaned_data.get('username')
111
-            user = User.objects.get(username=username)
112
-            if user.is_active:
111
+            try:
112
+                user = User.objects.get(username=username)
113
+            except User.DoesNotExist:
114
+                is_active = True
115
+            else:
116
+                is_active = user.is_active
117
+            if is_active:
113 118
                 if parameter.get(parameter.USERS_SELF_REGISTRATION):
114 119
                     messages.error(request, _('Login failed! You can do a password recorvery <a href="%(url_recover)s">here</a> or you can register <a href="%(url_register)s">here</a>.') %
115 120
                                    {'url_register': users.url_register(request), 'url_recover': users.url_password_recovery(request)})

Loading…
取消
儲存