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):
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)
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,
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
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