Also handle when there is no such user
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 3 Apr 2011 23:28:17 +0000 (18:28 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 3 Apr 2011 23:28:17 +0000 (18:28 -0500)
mediagoblin/auth/views.py

index 71c2d7a9b1a8daad5d25929f7d2f8bd00934752b..03c315768f3a34f8ac8fa04865b05641f29fb396 100644 (file)
@@ -79,11 +79,10 @@ def login(request):
     login_failed = False
 
     if request.method == 'POST' and login_form.validate():
-        #try:
         user = request.db.User.find_one(
             {'username': request.POST['username']})
 
-        if user.check_login(request.POST['password']):
+        if user and user.check_login(request.POST['password']):
             # set up login in session
             request.session['user_id'] = unicode(user['_id'])
             request.session.save()