cleanup after merge
authorRodney Ewing <ewing.rj@gmail.com>
Mon, 27 May 2013 15:39:34 +0000 (08:39 -0700)
committerRodney Ewing <ewing.rj@gmail.com>
Mon, 27 May 2013 15:39:34 +0000 (08:39 -0700)
mediagoblin/auth/__init__.py
mediagoblin/auth/tools.py
mediagoblin/auth/views.py
mediagoblin/plugins/basic_auth/__init__.py

index 53182eaac15385ae61b839d01b9369c7756db851..ae6c4b96f7364da60ebe8c530dae74d6e9bca4c7 100644 (file)
@@ -23,8 +23,8 @@ def check_login(user, password):
     return False
 
 
-def get_user(form):
-    return hook_handle("auth_get_user", form)
+def get_user(username):
+    return hook_handle("auth_get_user", username)
 
 
 def create_user(register_form):
index f38a292aa8bff9f2f11b469874292c4106742dbe..94a9781b6d2bf355033b7692fed22115d9c02254 100644 (file)
@@ -199,15 +199,12 @@ def send_fp_verification_email(user, request):
 
 
 def check_login_simple(username, password, username_might_be_email=False):
-    search = (User.username == username)
-    if username_might_be_email and ('@' in username):
-        search = or_(search, User.email == username)
-    user = User.query.filter(search).first()
+    user = auth.get_user(username)
     if not user:
         _log.info("User %r not found", username)
-        auth_lib.fake_login_attempt()
+        auth.fake_login_attempt()
         return None
-    if not auth_lib.bcrypt_check_password(password, user.pw_hash):
+    if not auth.check_password(password, user.pw_hash):
         _log.warn("Wrong password for %r", username)
         return None
     _log.info("Logging %r in", username)
index 109763ce5581a82bb3561888a5f762291116e3ae..b62602b3a50becc79412dfab4b9ba464ac4c03f4 100644 (file)
@@ -22,7 +22,6 @@ from mediagoblin.db.models import User
 from mediagoblin.tools.response import render_to_response, redirect, render_404
 from mediagoblin.tools.translate import pass_to_ugettext as _
 from mediagoblin.tools.mail import email_debug_message
-from mediagoblin.auth import lib as auth_lib
 from mediagoblin.auth import forms as auth_forms
 from mediagoblin.auth.tools import (send_verification_email,
                                     register_user,
@@ -301,7 +300,7 @@ def verify_forgot_password(request):
         cp_form = auth_forms.ChangePassForm(formdata_vars)
 
         if request.method == 'POST' and cp_form.validate():
-            user.pw_hash = auth_lib.bcrypt_gen_password_hash(
+            user.pw_hash = auth.gen_password_hash(
                 cp_form.password.data)
             user.fp_verification_key = None
             user.fp_token_expire = None
index 2fe161cbf91c3683159400ae97f671e7d37d331e..edbfacb58b3f9fa94070eec464140b98d7914518 100644 (file)
@@ -34,19 +34,17 @@ def check_login(user, password):
     return None
 
 
-def get_user(form):
-    if 'username' in form.data:
-        username = form.username.data
-        user = User.query.filter(
-            or_(
-                User.username == username,
-                User.email == username,
-            )).first()
-        return user
+def get_user(username):
+    user = User.query.filter(
+        or_(
+            User.username == username,
+            User.email == username,
+        )).first()
+    return user
 
 
 def create_user(registration_form):
-    user = get_user(registration_form)
+    user = get_user(registration_form.username.data)
     if not user and 'password' in registration_form:
         user = User()
         user.username = registration_form.username.data