Sfoglia il codice sorgente

BugFix: Login with non existing user

master
Dirk Alders 4 giorni fa
parent
commit
b63cfaa741
1 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. 7
    2
      views.py

+ 7
- 2
views.py Vedi File

@@ -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…
Annulla
Salva