Avoiding using '$or' query modifier since that's newer-mongo only.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 8 Sep 2011 04:23:44 +0000 (23:23 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 8 Sep 2011 04:23:44 +0000 (23:23 -0500)
mediagoblin/auth/views.py

index c18bfa349f5458429996c3db477522d9857fbed8..666426e6761c0970e49cc6bbf5bf96c462b1e4c4 100644 (file)
@@ -200,9 +200,12 @@ def forgot_password(request):
     fp_form = auth_forms.ForgotPassForm(request.POST)
 
     if request.method == 'POST' and fp_form.validate():
-        user = request.db.User.one(
-               {'$or': [{'username': request.POST['username']},
-               {'email': request.POST['username']}]})
+        # '$or' not available till mongodb 1.5.3
+        user = request.db.User.find_one(
+            {'username': request.POST['username']})
+        if not user:
+            user = request.db.User.find_one(
+                {'email': request.POST['username']})
 
         if user:
             user['fp_verification_key'] = unicode(uuid.uuid4())