Przeglądaj źródła

BugFix: Login with non existing user

master
Dirk Alders 4 dni temu
rodzic
commit
b63cfaa741
1 zmienionych plików z 7 dodań i 2 usunięć
  1. 7
    2
      views.py

+ 7
- 2
views.py Wyświetl plik

@@ -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)})

Ładowanie…
Anuluj
Zapisz